Skip to content

feat(postgrest): support aborting requests#1577

Closed
spydon wants to merge 1 commit into
worktree-SDK-1270from
feat/postgrest-abort-requests
Closed

feat(postgrest): support aborting requests#1577
spydon wants to merge 1 commit into
worktree-SDK-1270from
feat/postgrest-abort-requests

Conversation

@spydon

@spydon spydon commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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 the Abortable API, so the reasoning that removed cancellation-based features from #1560 no longer applies.

Stacked on top of #1560 (base branch worktree-SDK-1270). Review/merge that first.

New per-request API on PostgrestBuilder:

final abort = Completer<void>();
Timer(const Duration(seconds: 5), abort.complete);
try {
  final data = await supabase.from('users').select().abortCompleter(abort);
} on RequestAbortedException {
  // The request was aborted before it completed.
}
  • PostgrestBuilder.abortCompleter(Completer<void> completer) — aborts the request when completer completes. Available on the query, filter and transform builders, and preserved across further chaining.
  • When triggered, the request throws RequestAbortedException (re-exported from package:http).
  • Aborting short-circuits the auto-retry loop: an aborted request is intentional and is never retried.
  • The abortable path is only used when a completer is set, so all existing requests keep their exact current send behavior.

Design notes

  • The API name follows the proposal in feat(postgrest): abort requests #1368 (abortCompleter). supabase-js uses abortSignal; since Dart has no AbortSignal, a Completer<void> is the idiomatic equivalent. Open to abortSignal(Future<void>) instead if preferred, which would also allow Future.delayed-based timeouts directly.
  • Aborting depends on the underlying Client supporting it (the platform IOClient / BrowserClient in http 1.6 do).

Request timeout

database.configuration.request_timeout is still not_applicable in the matrix. It is now technically feasible to build a real per-request timeout on top of this (a Future.delayed as 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_cancellationimplemented

Tests

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

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.
@spydon spydon requested a review from a team as a code owner July 10, 2026 11:05
@github-actions github-actions Bot added the postgrest This issue or pull request is related to postgrest label Jul 10, 2026
@spydon spydon marked this pull request as draft July 10, 2026 11:12
@spydon

spydon commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

#1368 already deals with this, so I'm closing this one.

@spydon spydon closed this Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postgrest This issue or pull request is related to postgrest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant