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(web-server): ignore future socket errors #3402
base: master
Are you sure you want to change the base?
Conversation
Karma sometimes reports uncaught exceptions (ECONNRESET) which causes it to exit the process with a non-zero exit code. Fixes karma-runner#3295
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
✅ Build karma 62 completed (commit 6b00be646c by @mgroenhoff) |
✅ Build karma 2460 completed (commit 6b00be646c by @mgroenhoff) |
@googlebot I signed it! |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
✅ Build karma 61 completed (commit 6b00be646c by @mgroenhoff) |
@@ -93,6 +93,8 @@ function createWebServer (injector, config) { | |||
|
|||
server.on('upgrade', function (req, socket, head) { | |||
log.debug(`upgrade ${req.url}`) | |||
// ignore future socket errors | |||
socket.on('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.
Seems like this will cause all errors to be ignored after we start the two-way socket-io.
The spurious errors from #3295 only occur after the run completes. Isn't the time to turn off errors?
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 would say that you don't want those socket errors to crash the entire Karma process and this prevents just that. It still allows for the upgrade handler(s) to attach their own error event handlers.
Maybe I should change the comment so it says exactly that: that it only prevents the process from crashing.
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.
In fact. I think this is somewhat similar to what Node.js does when it's HTTP server receives a new connection. It attaches an error handler to prevent it from going down. It forwards it to the 'clientError' event on the server, which when emitted does not crash if it does not have any handlers. But in the case if an upgrade request it totally lets go of the socket and removes that error handler so the socket is entirely yours.
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.
Sorry I missed your reply.
Yes, just change the comment.
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.
The spurious errors from #3295 only occur after the run completes. Isn't the time to turn off errors?
I agree. While this fixes the problem it will swallow errors in other situations. At the bare minimum, it should log an error as a warning similar to https://github.com/karma-runner/karma/blob/master/lib/server.js#L145. Ideally, it should also reset the handler after the complete event is received to target specifically #3295, where we don't care about the browser errors anymore.
✅ Build karma 2783 completed (commit 8f39f90852 by @mgroenhoff) |
✅ Build karma 386 completed (commit 8f39f90852 by @mgroenhoff) |
✅ Build karma 385 completed (commit 8f39f90852 by @mgroenhoff) |
Any update on this? Is anyone who knows the code willing to do the required review? |
I reviewed but never received updates. |
@mgroenhoff do we still need to merge this PR? |
fe000ad
to
b9831cc
Compare
6fe6df0
to
56cda53
Compare
Karma sometimes reports uncaught exceptions (ECONNRESET) which causes it to exit the process with a non-zero exit code.
Fixes #3295