-
Notifications
You must be signed in to change notification settings - Fork 530
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
Handle JSON parse errors in watch implementation #250
Conversation
src/watch.ts
Outdated
@@ -1,4 +1,5 @@ | |||
import { LineStream } from 'byline'; |
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.
Is this still used?
Also not sure the linter didn't pick this up.
package.json
Outdated
@@ -56,6 +56,7 @@ | |||
"byline": "^5.0.0", |
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 doesn't seem to be needed anymore either?
This change "handles" JSON parse parse errors in the watch implementation by ignoring them: the JSONStream implementation ignores parsing errors. The request might result in invalid JSON if, for example, the HTTP connection is abruptly terminated (and a partial line is piped to the transform stream). The code this commit replaces would raise an uncaught exception exception on parse errors. An alternative approach to this commit would invoke the `done` callback with parse errors, but that could result in multiple invocations of the `done` callback.
@silasbw Thanks for fixing this and for adding a test /lgtm |
/assign @brendandburns |
/approve thanks! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brendandburns, silasbw The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This change "handles" JSON parse errors in the watch implementation by
ignoring them: the JSONStream implementation ignores parsing errors.
The request might result in invalid JSON if, for example, the HTTP connection
is abruptly terminated (and a partial line is piped to the transform stream).
The code this commit replaces would raise an uncaught exception exception on
parse errors. An alternative approach to this commit would invoke the
done
callback with parse errors, but that could result in multiple invocations of
the
done
callback.