Skip to content

Commit

Permalink
fix(fs.walk): do not emit events after destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Aug 15, 2020
1 parent 7f48cc8 commit c0931bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/fs/fs.walk/src/readers/async.spec.ts
Expand Up @@ -53,15 +53,15 @@ describe('Readers → Async', () => {
reader.read();
});

it('should do not emit "entry" event after first broken scandir call', (done) => {
it('should do not emit events after first broken scandir call', (done) => {
const reader = new TestReader('directory');

const firstFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'a', path: 'directory/a' });
const secondFakeDirectoryEntry = tests.buildFakeDirectoryEntry({ name: 'b', path: 'directory/b' });

reader.scandir.onFirstCall().yields(null, [firstFakeDirectoryEntry, secondFakeDirectoryEntry]);
reader.scandir.onSecondCall().yields(tests.EPERM_ERRNO);
reader.scandir.onThirdCall().yields(tests.EPERM_ERRNO);
reader.scandir.onSecondCall().yieldsAsync(tests.EPERM_ERRNO);
reader.scandir.onThirdCall().yieldsAsync(tests.EPERM_ERRNO);

/**
* If the behavior is broken, then a third scandir call will trigger an unhandled error.
Expand Down
2 changes: 1 addition & 1 deletion packages/fs/fs.walk/src/readers/async.ts
Expand Up @@ -87,7 +87,7 @@ export default class AsyncReader extends Reader {
}

private _handleError(error: Error): void {
if (!common.isFatalError(this._settings, error)) {
if (this._isDestroyed || !common.isFatalError(this._settings, error)) {
return;
}

Expand Down

0 comments on commit c0931bf

Please sign in to comment.