Repository navigation
fix(csv-parse): only destroy on end when the stream has destroy (fix #409) - #538
Merged
Merged
Conversation
Member
|
#513 is now merged, could you rebase your PR ? |
…daltas#409) The browser builds bundle a stream polyfill whose Transform has no `destroy` method. When the parser stops because of the `to` or `to_line` options, or ends on an empty input, it registers `this.destroy` as an `end` listener, which throws "listener argument must be a function". Register the listener only when `destroy` is a function. Node.js streams always have it, so their behavior is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b84330808
force-pushed
the
fix/csv-parse-browser-destroy
branch
from
October 22, 2026 02:00
1ae3b76 to
a33423b
Compare
Contributor
Author
|
Rebased! The |
Member
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #409
The browser builds of csv-parse (
csv-parse/browser/esm, iife, umd) bundle a stream polyfill whose Transform has nodestroymethod. When the parser stops early because oftoorto_line, it callsthis.destroy()once the stream has ended (and on an empty input it runsthis.on("end", this.destroy)), which throws in the browser (this.destroy is not a function, or"listener" argument must be a functionfor the listener). Parsing itself still finishes, which is why the report says everything seems to work apart from the error.This only calls or registers
destroywhen it is a function, which is the guard you suggested in #333 when the same thing came up in the browser. Node.js streams always havedestroy, so nothing changes there.The new tests in
test/api.stream.destroy.tsremovedestroyfrom a parser (withautoDestroy: false, otherwise Node calls it itself at finish) and coverto,to_lineand empty input. They fail on master with the same error as the report. I also rebuilt the bundles locally and checked thatdist/esm/index.jsno longer throws withtoandto_line. I leftdist/out of the PR since it's regenerated on release.I used Claude Code to write this change.