-
Notifications
You must be signed in to change notification settings - Fork 181
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
Streams: don't error when writing closing bytes #546
Conversation
|
I'm not sure why the tests failed, can I do anything to help with this PR? |
ping |
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.
Yeah, I'm ok with this; seems mostly harmless. If there's some other writing error, we usually throw, but in this case, we've already sent the "content" of the request, so whether or not these final bytes get through seems inconsequential, reinforced by the fact that, empirically, browsers seem to not care either.
The number of empty try-catches throughout the request code kind of pains my soul though. The code is getting ugly and is probably due for a larger refactor/cleanup.
Thank you! I can see why you were reluctant to merge this PR then :) |
@quinnj Generally, a write error just isn't something a web service can do anything about. It means the connection or route went away, user closed browser, closed a tab, navigated away, lost their wifi signal, etc. Perhaps it might be nice to track some statistics about it... in the aggregate they might be interesting (but your reverse proxy will know about them), applications simply can't be concerned with these -- they are basically not actionable. So, if you were going to refactor, you could make a function an application could override, but just set its body to |
A common error when using Firefox on localhost is:
Which led to lots of confusing error messages when using Pluto.jl. I believe the error is due to Firefox closing the IO before receiving the bytes
0\r\n\r\n
when navigating to another page.This PR simply wraps the closing
write
call in atry catch
block - I believe that this only affects the situation where a clean close is not possible, but both ends already know that the connection is closing. (I should point out that I am not familiar with the HTTP protocol!)