-
Notifications
You must be signed in to change notification settings - Fork 183
Fix exception on connection errors in chrome. #761
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
22ead7a
Fix exception on connection errors in chrome.
mefyl 048011e
Merge master into bugfix/null-response-chrome.
mefyl b09155c
Also fix null response bug in sync client.
mefyl 658e67e
cohttp-lwt-jsoo: Factor body construction.
mefyl 115173a
Add log when replacing null response with the empty string.
mefyl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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.
Sure, IIRC there's even a comment by @avsm there that it is duplicated.
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 gave it a try, the only difference is the async version wrapping the response in a
Lwt.t, so we'd need to parameterize the whole thing over the "future" monad. But really the wholeMake_client_syncandMake_client_asyncare 99% duplicated, a simple abstraction over that monad would factor it (someone has been veeeery lazy or in a hurry when writing this 😅).I don't mind taking a look, but honestly that should be a different PR.
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.
Regarding the reproduction, I know of no easy way. AFAICT it's the internal XHR implementation of chrome, and it's not clear when to me why
responseTypeis"arraybuffer", butresponseisnull. It looks like a mild bug according to MDN, but since it's meant to be used from javascript and everything fits everywhere™ in that magical world, it's probably not much of an issue - and by that I mean not a bigger issue that the rest of the language and libraries.I can't reproduce it myself, I just get that exception reported a few times a day from our app running in the wild, all I can say is that it's possible to reach this state with a fairly recent chrome (electron 12). I thought I had a reproduction in the js test suite, which prompted me to drop this PR, but I was empirically wrong it seems.
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.
Fair enough. Given how complicated is managing exceptions across ocaml and js, I think it makes sense to be a bit proactive here. We should probably add a LOG message that the call returned a
nullresponse though, so it does not come unnoticed if it happens by mistakeThere 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.
That's good for me. Thanks for putting in the effort!
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.
Done