-
Notifications
You must be signed in to change notification settings - Fork 43
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(#301): Handle JSONStream.parse() errors more gracefully #306
Conversation
ced6da4
to
2e38b3b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a master of Node.js streaming logic. If you have other ideas, please let me know!
.pipe(JSONStream.parse()) | ||
.pipe( | ||
transform.on("error", (error) => { | ||
throw error; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't strictly necessary, but it did convert an error location from within node:stream
to this userland function.
proc.on("error", (error) => reject(error)); | ||
proc.on("close", () => { | ||
if (errorMessage) { | ||
return reject(new Error(errorMessage)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the error:
➜ node ../../dist/bin.js
audit-ci version: 6.5.0
Yarn Berry audit report results:
node:events:491
throw er; // Unhandled 'error' event
^
Error: Internal Error: audit-ci-yarn-workspace@workspace:.: This package doesn't seem to be present in your lockfile; run "yarn install" to update the lockfile
at Stream.<anonymous> (/Users/quinn/Dev/quinnturner/audit-ci/dist/common.js:132:15)
at Stream.emit (node:events:525:35)
at parser.onError (/Users/quinn/Dev/quinnturner/audit-ci/node_modules/JSONStream/index.js:142:12)
at proto.charError (/Users/quinn/Dev/quinnturner/audit-ci/node_modules/jsonparse/jsonparse.js:90:8)
at proto.write (/Users/quinn/Dev/quinnturner/audit-ci/node_modules/jsonparse/jsonparse.js:154:23)
at Stream.<anonymous> (/Users/quinn/Dev/quinnturner/audit-ci/node_modules/JSONStream/index.js:23:12)
at stream.write (/Users/quinn/Dev/quinnturner/audit-ci/node_modules/through/index.js:26:11)
at Stream.ondata (node:internal/streams/legacy:20:31)
at Stream.emit (node:events:513:28)
at Stream.write (/Users/quinn/Dev/quinnturner/audit-ci/node_modules/event-stream/index.js:210:12)
Emitted 'error' event on ReadlineTransform instance at:
at ReadlineTransform.onerror (node:internal/streams/readable:785:14)
at ReadlineTransform.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Node.js v19.3.0
I wouldn't say this is the cleanest error of all time, but it is much better than a JSONStream.parse()
error!
Signed-off-by: Quinn Turner <quinnturnertech@gmail.com>
2e38b3b
to
4bdaf5b
Compare
No description provided.