Handle transform problems correctly
Summary: This fixes a piece of promise code that didn’t handle nested rejections. This caused the packager not to recover from transform errors, as the server was waiting for an in-limbo promise forever. Reviewed By: cpojer Differential Revision: D4207138 fbshipit-source-id: 8e94ddebd033073f90b79b1c4820c09ac98a4932
This commit is contained in:
parent
a477aec10d
commit
a10eee4372
|
@ -223,19 +223,24 @@ class Module {
|
|||
// never be transformed anyway.
|
||||
invariant(_transformCode != null, 'missing code transform funtion');
|
||||
invariant(_transformCacheKey != null, 'missing cache key');
|
||||
this._readSourceCode().then(sourceCode => {
|
||||
return _transformCode(this, sourceCode, transformOptions)
|
||||
.then(freshResult => {
|
||||
TransformCache.writeSync({
|
||||
filePath: this.path,
|
||||
sourceCode,
|
||||
transformCacheKey: _transformCacheKey,
|
||||
transformOptions,
|
||||
result: freshResult,
|
||||
});
|
||||
callback(undefined, freshResult);
|
||||
});
|
||||
}, callback);
|
||||
this._readSourceCode()
|
||||
.then(sourceCode =>
|
||||
_transformCode(this, sourceCode, transformOptions)
|
||||
.then(freshResult => {
|
||||
TransformCache.writeSync({
|
||||
filePath: this.path,
|
||||
sourceCode,
|
||||
transformCacheKey: _transformCacheKey,
|
||||
transformOptions,
|
||||
result: freshResult,
|
||||
});
|
||||
return freshResult;
|
||||
})
|
||||
)
|
||||
.then(
|
||||
freshResult => process.nextTick(callback, null, freshResult),
|
||||
error => process.nextTick(callback, error),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue