Skip to content

fix: pass parse errors to transform callback instead of throwing - #38

Merged
rvagg merged 2 commits into
nodejs:mainfrom
trivikr:fix-parse-error-callback
Nov 2, 2026
Merged

rvagg merged 2 commits into
nodejs:mainfrom
trivikr:fix-parse-error-callback

Conversation

@trivikr

@trivikr trivikr commented Nov 2, 2026

Copy link
Copy Markdown
Member

commitStream()'s transform called addLine() without a try/catch. When a line came before the first commit header, the parse error was thrown out of transform and never passed to callback. A direct write() threw synchronously instead of emitting 'error'. The message (Something unexpected occurred) also didn't say what was wrong.

const stream = commitStream()
stream.on('error', (err) => console.log('error event:', err.message))
stream.write('garbage')
// expected: error event: Unexpected line before first "commit" header: garbage
// actual:   throws Error: Something unexpected occurred

This PR passes the error to callback(err) and changes the message to Unexpected line before first "commit" header: <line>. It also adds regression tests for write() and pipeline().

Comment thread commit-stream.js Resolved
@trivikr
trivikr requested a review from rvagg November 2, 2026 07:51
@rvagg

rvagg commented Nov 2, 2026

Copy link
Copy Markdown
Member

needs a rebuil and comitted types/commit-stream.d.ts.map.

Co-authored-by: Rod Vagg <rod@vagg.org>
@trivikr
trivikr force-pushed the fix-parse-error-callback branch from 346e844 to 38c1cc1 Compare November 2, 2026 07:57
@rvagg
rvagg merged commit f0d2a32 into nodejs:main Nov 2, 2026
7 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 2, 2026
## [3.0.1](v3.0.0...v3.0.1) (2026-11-02)

### Bug Fixes

* pass parse errors to transform callback instead of throwing ([#38](#38)) ([f0d2a32](f0d2a32))
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 3.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@trivikr
trivikr deleted the fix-parse-error-callback branch November 2, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants