Skip to content

fix(core): close stream instead of destroying it#3610

Merged
merceyz merged 2 commits intomasterfrom
merceyz/fix/close-stream
Oct 22, 2021
Merged

fix(core): close stream instead of destroying it#3610
merceyz merged 2 commits intomasterfrom
merceyz/fix/close-stream

Conversation

@merceyz
Copy link
Copy Markdown
Member

@merceyz merceyz commented Oct 21, 2021

What's the problem this PR addresses?

When parsing tar archives we destroy the PassThrough stream as soon as the tar.ParseStream emits the close event but in Node 17 this causes a ERR_STREAM_PREMATURE_CLOSE error.

Fixes #3597

How did you fix it?

Call .end on the stream instead of .destroy which lets it finish correctly.

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.

@merceyz merceyz requested a review from arcanis as a code owner October 21, 2021 14:14
@merceyz merceyz force-pushed the merceyz/fix/close-stream branch from f4ac386 to 95455f2 Compare October 21, 2021 14:16
arcanis
arcanis previously approved these changes Oct 21, 2021
@merceyz merceyz force-pushed the merceyz/fix/close-stream branch from 603c4b7 to c8cb5fc Compare October 21, 2021 16:48
@merceyz merceyz requested a review from arcanis October 21, 2021 16:50
@merceyz merceyz enabled auto-merge (squash) October 21, 2021 16:50
@aduh95
Copy link
Copy Markdown
Contributor

aduh95 commented Oct 21, 2021

FWIW this repo could be eligible to Node.js CITGM initiative which would allow to catch this kind of bugs before each new version of Node.js is released.

nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Oct 22, 2021
@merceyz merceyz merged commit a450f9e into master Oct 22, 2021
@merceyz merceyz deleted the merceyz/fix/close-stream branch October 22, 2021 14:32
@xfournet
Copy link
Copy Markdown
Contributor

@merceyz thanks for the fix! Is a 3.0.3 release planned soon for this bug fix ?

@merceyz
Copy link
Copy Markdown
Member Author

merceyz commented Oct 25, 2021

We plan on releasing v3.1 soon™, in the meantime you can use the canary release

yarn set version canary

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?]: node17 compat: │ Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close

4 participants