-
Notifications
You must be signed in to change notification settings - Fork 653
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 JS websocket throws an ISE on error on Safari and Firefox #5670
Conversation
We're seeing the error event fire when the websocket closes as a result of a network error on Safari and Firefox. Since the socket has already been opened, the coroutine has already been resumed and this throws an IllegalStateException ("Already resumed").
👷 Deploy request for apollo-android-docs pending review.Visit the deploys page to approve it
|
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.
Looks good to me 👍 Thanks!
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.
Good catch!
Also looks like that code is still in Ktor indeed, a PR there would be great!
PS: how hard would it be to add a test for that? I think KGP can do firefox tests with Karma? |
I can take a stab at adding a test over the weekend! |
Hmm. I'm afraid I'm a bit stumped on this one. The challenge is that you need a websocket server running outside of the browser that dies (uncleanly) after a connection has been established. I think the easiest way to do this would be to have a little node script that runs the websocket server, which you start up beforehand (eg a shell-based gradle task with a Can you think of a better way? I found this very old Karma plugin, but I don't see an easy way to modify |
Urg, right. No mock server in the browser :/. Not sure it's worth the extra complexity then, especially since the fix is solid. I'm merging this as is as we can revisit browser tests that need a MockServer next time. Thanks for looking at it! |
We're seeing the error event fire when the websocket closes as a result of a network error on Safari and Firefox. Since the socket has already been opened, the coroutine has already been resumed and this throws an IllegalStateException ("Already resumed").
I can submit this same patch up to ktor, since I think that's where this code came from originally.