mirror of https://github.com/status-im/metro.git
Multiple requests to the Delta Bundler when there is an error should produce an Error
Reviewed By: jeanlauliac Differential Revision: D5814215 fbshipit-source-id: 9a72057078819d07ddbd5d4f949d7bdf13aff29e
This commit is contained in:
parent
3401cfe768
commit
9294f5a46a
|
@ -103,6 +103,14 @@ class DeltaCalculator extends EventEmitter {
|
|||
|
||||
try {
|
||||
result = await this._currentBuildPromise;
|
||||
} catch (error) {
|
||||
// In case of error, we don't want to mark the modified files as
|
||||
// processed (since we haven't actually created any delta). If we do not
|
||||
// do so, asking for a delta after an error will produce an empty Delta,
|
||||
// which is not correct.
|
||||
modifiedFiles.forEach(file => this._modifiedFiles.add(file));
|
||||
|
||||
throw error;
|
||||
} finally {
|
||||
this._currentBuildPromise = null;
|
||||
}
|
||||
|
|
|
@ -234,4 +234,19 @@ describe('DeltaCalculator', () => {
|
|||
|
||||
expect(onChangeFile.mock.calls.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should retry to build the last delta after getting an error', async () => {
|
||||
await deltaCalculator.getDelta();
|
||||
|
||||
fileWatcher.emit('change', {eventsQueue: [{filePath: '/foo'}]});
|
||||
|
||||
Bundler.prototype.getShallowDependencies.mockImplementation(async () => {
|
||||
throw new Error('error');
|
||||
});
|
||||
|
||||
await expect(deltaCalculator.getDelta()).rejects.toBeInstanceOf(Error);
|
||||
|
||||
// This second time it should still throw an error.
|
||||
await expect(deltaCalculator.getDelta()).rejects.toBeInstanceOf(Error);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue