Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fslib): don't destroy createReadStream in ZipFS before it finishes #2159

Merged
merged 2 commits into from
Nov 26, 2020

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented Nov 22, 2020

What's the problem this PR addresses?

There is a race condition in the createReadStream implementation in ZipFS, if the file the stream is created for is large enough the stream will be destroyed before the write finishes.

Fixes #2004

How did you fix it?

Avoid calling destroy on successful reads and let the PassThrough autoDestroy itself, applied the same changes to createWriteStream.
I also made the read async to speed it up a bit

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

Sorry, something went wrong.

Comment on lines -512 to +513
expect(() => iter.next()).rejects.toThrow(`Directory handle was closed`);
// FIXME: This assertion fails
// await expect(() => iter.next()).rejects.toThrow(`Directory handle was closed`);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This failed before this PR but wasn't awaited so it wasn't caught

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@merceyz merceyz force-pushed the merceyz/zipfs-readstream-close branch from ef7ac79 to 49deb21 Compare November 23, 2020 21:30

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@merceyz merceyz force-pushed the merceyz/zipfs-readstream-close branch from 147ef21 to ef79d1d Compare November 23, 2020 22:09
@merceyz merceyz requested a review from arcanis November 23, 2020 23:39
@merceyz merceyz merged commit 5e8630b into master Nov 26, 2020
@merceyz merceyz deleted the merceyz/zipfs-readstream-close branch November 26, 2020 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] ZipFS ReadStream missing 'end' event sometimes on Node v14
2 participants