Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Starting from version
1.5.0
ofpackage:http
, some client implementations (including the default ones from that package) support cancelling requests (with a mechanism similar toAbortController
in JS, represented as a future that, when completed, aborts the request).While we are already handling cancellations quite well in our sync client implementation (we currently cancel the stream subscription on the HTTP stream, closing the underlying connection), one thing that's not currently cancellable is establishing the connection. Especially when the user has poor connectivity, waiting for headers to be received just to abort the request at that point can be inefficient. Adopting abortable requests can improve this.
By passing an abort trigger to the request, the client will behave as follows:
.send()
),send()
itself will throw aRequestAbortedException
, which extendsClientException
.RequestAbortedException
is injected into the Dart stream by the client.In both cases, we forward this exception on the stream that
_dartSyncIteration
and_ActiveRustStreamingIteration.receiveLines
listen to, which will cause them to abort and rethrow. The exception is not visible to users becausestreamingSync
catches it and does nothing if it hapens while aborting the sync.