-
-
Notifications
You must be signed in to change notification settings - Fork 643
Feature/add cancellation support #1510
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
base: main
Are you sure you want to change the base?
Feature/add cancellation support #1510
Conversation
- Add CancellationToken class for operation cancellation - Add CancelledException for cancelled operations - Integrate cancellation into BaseOptions, QueryOptions, MutationOptions - Implement cancellation handling in QueryManager - Add queryCancellable() and mutateCancellable() convenience methods - Add comprehensive test suite (7 tests) - Add usage documentation
|
|
||
| 3. **Error Handling**: Cancelled operations will complete with an `OperationException` containing a `CancelledException` as the `linkException`. | ||
|
|
||
| 4. **Network Cleanup**: Cancelling an operation will attempt to cancel the underlying network request, but depending on the transport layer and server, the request may still complete on the server side. |
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.
can't really see how it cancels the underlying request? can you explain?
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.
you are right i haven't noticed that the underlying http request wasn't actually cancelled, only the subscription was cancelled.
I now added true HTTP request cancellation to the graphql package.
-
Created custom HttpLink with platform-specific cancellation support
-
Web: Uses XMLHttpRequest.abort() → shows "(canceled)" in Chrome DevTools
-
IO (Linux/Desktop/Mobile): Uses HttpClient.close(force: true) + request.abort() → terminates TCP connection
-
Added CancellationContextEntry to pass the token through the Link chain
-
Added web package dependency (replaces deprecated dart:html)
-
Added additional tests for http cancellation
Result:
operation.cancel() now actually aborts the underlying HTTP request
Not just ignoring the response — the network connection is terminated
I verified it, in chrome and linux the http request gets actually cancelled
- Created custom HttpLink with platform-specific cancellation support - Web: Uses XMLHttpRequest.abort() → shows "(canceled)" in Chrome DevTools - IO (Linux/Desktop/Mobile): Uses HttpClient.close(force: true) + request.abort() → terminates TCP connection - Added CancellationContextEntry to pass the token through the Link chain - Added web package dependency (replaces deprecated dart:html) Result: operation.cancel() now actually aborts the underlying HTTP request Not just ignoring the response — the network connection is terminated
|
|
||
| MutationOptions<TParsed> copyWithPolicies(Policies policies) => | ||
| MutationOptions( | ||
| MutationOptions<TParsed> copyWithPolicies(Policies policies) => MutationOptions( |
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.
You should run dart format --line-length=80 ./
There is quite a lot of irrelevant white space noise in this PR
As needed since 6 years here is cancellation support #181
-> no breaking changes
-> all tests pass