Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: support request cancellation on js/wasm #38003
Also see https://stackoverflow.com/a/47250621/622447 for more relevant information.
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 <email@example.com> Reviewed-by: Richard Musiol <firstname.lastname@example.org>