Skip to content

Support cancellation of tasks with FetchHTTPClient#157

Open
xbhatnag wants to merge 1 commit intomainfrom
fetch-client
Open

Support cancellation of tasks with FetchHTTPClient#157
xbhatnag wants to merge 1 commit intomainfrom
fetch-client

Conversation

@xbhatnag
Copy link
Copy Markdown
Collaborator

@xbhatnag xbhatnag commented May 8, 2026

The client now supports cancellation during fetch() API call or during reading of the response body!

The example app is now configured to cancel a request after 10 seconds to demonstrate this functionality.

Screenshot 2026-05-08 at 12 16 18 PM

The client now supports cancellation during `fetch()` API call
and during reading of response body.
@xbhatnag xbhatnag requested review from FranzBusch and guoye-zhang May 8, 2026 19:17
@xbhatnag xbhatnag self-assigned this May 8, 2026
@xbhatnag xbhatnag added the 🔨 semver/patch No public API change. label May 8, 2026
@JSClass(from: .global) struct AbortController: @unchecked Sendable {
@JSGetter var signal: JSObject?
@JSFunction init() throws(JSException)
@JSFunction func abort() throws(JSException)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these functions safe to call from any threads?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no expert on how this translates to JS, but isn't JS single-threaded, making WASM single-threaded, making all the asynchronous contexts in Swift also single-threaded?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that multithreading is supported in WASM: https://webassembly.org/features/

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I learned :) @MaxDesiatov might know more about this specific question...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants