feat(postgrest): support aborting requests#1577
Closed
spydon wants to merge 1 commit into
Closed
Conversation
Add PostgrestBuilder.abortCompleter(Completer<void>), which aborts the in-flight request when the completer completes, using the http 1.5+ Abortable API. Aborted requests throw RequestAbortedException and are never retried. Implements database.using_modifiers.request_cancellation.
Contributor
Author
|
#1368 already deals with this, so I'm closing this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds request aborting to the PostgREST client, following up on the discussion in #1560 (comment): now that the repo is on
http ^1.6.0, in-flight requests can actually be cancelled via theAbortableAPI, so the reasoning that removed cancellation-based features from #1560 no longer applies.New per-request API on
PostgrestBuilder:PostgrestBuilder.abortCompleter(Completer<void> completer)— aborts the request whencompletercompletes. Available on the query, filter and transform builders, and preserved across further chaining.RequestAbortedException(re-exported frompackage:http).Design notes
abortCompleter).supabase-jsusesabortSignal; since Dart has noAbortSignal, aCompleter<void>is the idiomatic equivalent. Open toabortSignal(Future<void>)instead if preferred, which would also allowFuture.delayed-based timeouts directly.Clientsupporting it (the platformIOClient/BrowserClientinhttp1.6 do).Request timeout
database.configuration.request_timeoutis stillnot_applicablein the matrix. It is now technically feasible to build a real per-request timeout on top of this (aFuture.delayedas the abort trigger), so that entry could be revisited in a follow-up if we want a first-class timeout option.Compliance matrix
database.using_modifiers.request_cancellation→implementedTests
packages/postgrest/test/abort_test.dart: aborting a GET, aborting an insert (POST), no-retry-on-abort, normal completion when never triggered, and preservation across chaining.Closes #1368