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
Labels
arch-wasm WebAssembly issues FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-JS
Milestone

Comments

@dmitshur
Copy link
Contributor

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 dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. FeatureRequest arch-wasm WebAssembly issues OS-JS labels Mar 22, 2020
@dmitshur dmitshur added this to the Backlog milestone Mar 22, 2020
@dmitshur
Copy link
Contributor Author

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 modified the milestones: Backlog, 1.11, Go1.11 Mar 22, 2020
@gopherbot
Copy link

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>
@golang golang locked and limited conversation to collaborators Mar 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues FeatureRequest FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-JS
Projects
None yet
Development

No branches or pull requests

2 participants