Skip to content
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

net/http: support request cancellation on js/wasm #38003

Closed
dmitshur opened this issue Mar 22, 2020 · 2 comments
Closed

net/http: support request cancellation on js/wasm #38003

dmitshur opened this issue Mar 22, 2020 · 2 comments

Comments

@dmitshur
Copy link
Member

@dmitshur dmitshur commented Mar 22, 2020

We should implement HTTP request cancellation via request context cancellation on js/wasm now that AbortSignal has become part of the DOM living standard and many major browsers have implemented it.

Also see https://stackoverflow.com/a/47250621/622447 for more relevant information.

/cc @neelance @johanbrandhorst @bradfitz

@dmitshur
Copy link
Member Author

@dmitshur dmitshur commented Mar 22, 2020

This is already implemented! 🎉

It was implemented 2 years ago in the original CL 114515. See here and here. I just missed it on my first look through the code.

@dmitshur dmitshur closed this Mar 22, 2020
@dmitshur dmitshur modified the milestones: Backlog, 1.11, Go1.11 Mar 22, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Mar 29, 2020

Change https://golang.org/cl/226204 mentions this issue: net/http: release callbacks after fetch promise completes

gopherbot pushed a commit that referenced this issue Apr 2, 2020
When the request context was canceled, the Transport.RoundTrip method
could return before the fetch promise resolved. This would cause the
success and failure callback functions to get called after they've
been released, which in turn prints a "call to released function"
error to the console.

Avoid that problem by releasing the callbacks after the fetch promise
completes, by moving the release calls into the callbacks themselves.
This way we can still return from the Transport.RoundTrip method as
soon as the context is canceled, without waiting on the promise to
resolve. If the AbortController is unavailable and it's not possible to
abort the fetch operation, the promise may take a long time to resolve.

For #38003.

Change-Id: Ied1475e31dcba101b3326521b0cd653dbb345e1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/226204
Reviewed-by: Johan Brandhorst <johan.brandhorst@gmail.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.