Repository navigation
feat(postgrest): add retry, requestTimeout, abortSignal and setHeader to the typed builders - #1907
Conversation
… to the typed builders
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: supabase/supabase-flutter/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughTyped PostgREST builders now configure headers, retries, request timeouts, and abort signals. Table requests retain these options, and the HTTP executor applies them to count and non-count requests. Tests cover option propagation and request behavior. ChangesTyped request options
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant TypedBuilder as PostgrestTypedQueryBuilder
participant Request as PostgrestTableRequest
participant Executor as PostgrestHttpTableExecutor
participant Builder as PostgrestBuilder
TypedBuilder->>Request: Carry configured request options
Request->>Executor: Submit request when awaited
Executor->>Builder: Apply options and render request
Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change adds per-request headers, retry, timeout, and cancellation controls to typed PostgREST builders. No merge-blocking issue was found, and tests cover the new behavior. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new controls reuse existing request handling, preserve request-scoped headers and do not enable automatic write retries. Remaining uncertainty concerns the outcome of cancelled writes and how custom executors handle identity-bearing options. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…xecutor (#1939) ## What #1857 was merged before the plugin seam was ready. This takes the plugin system and the executor extension point back out of the public API. #1940 brings them back for review. The typed builders keep their internal structure: they still collect a `PostgrestTableRequest` and run it through `PostgrestHttpTableExecutor`. Several later PRs build on that (#1907, #1913, #1910, #1897 and others). Only the public surface is removed: - `SupabaseClientPlugin`, `SupabaseClient(plugins:)`, `SupabaseClient.plugins`, `Supabase.initialize(plugins:)` and the plugin resume handling in the Flutter lifecycle listener, and `testSupabaseClient(plugins:)`. - `PostgrestClient.table(executor:)`, `SupabaseQuerySchema(tableExecutor:)` and `PostgrestTypedBuilder.request`. - `PostgrestTableExecutor`, `PostgrestHttpTableExecutor`, `PostgrestTableRequest`, `PostgrestTableResult`, `PostgrestTableOperation`, `PostgrestResultShape`, `PostgrestEmbeddedPage`, `PostgrestExplainOptions` and `PostgrestRequestOptions` are no longer exported. - `PostgrestTypedQueryBuilder` and `SupabaseTypedQueryBuilder` take a `client` instead of an `executor`. The matching `sdk-compliance.yaml` entries and the plugin paragraph in `MIGRATION.md` are removed, and `AGENTS.md` describes the executor as internal. ## Tests `table_executor_test.dart`, `client_plugin_test.dart` and the Flutter `plugin_test.dart` are removed with the API they cover. They come back in #1940. The update/delete test in `typed_query_test.dart` used to assert on `request.filter`. It now checks the filter on the request that goes out. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Breaking Changes** * Supabase client initialization no longer accepts plugins, and plugin lifecycle and request-wrapping support have been removed. * Typed table queries no longer allow supplying a custom executor. Supporting typed-query types and request details are no longer exposed through the main library exports. * **Documentation** * Updated query-building and migration guidance to reflect the current typed table query behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
The untyped builders let a caller control each request, but the typed builders returned by
client.table(...)could not do any of it. A typed caller had no way to cancel a request, override the timeout or retry policy, or set a header. That includes theAuthorizationheader, which is how a single request overrides the token. TheFuture.timeout()the typed builder inherits only stops waiting for the result, while the HTTP request keeps running.This adds
retry({bool enabled, int? count}),requestTimeout(Duration),abortSignal(Future<void>)andsetHeader(String, String)toPostgrestTypedQueryBuilder,PostgrestTypedFilterBuilder,PostgrestTypedTransformBuilderandPostgrestTypedBuilder. Each one returns its own builder type, so the chain continues. Unlike the untyped API,abortSignalis available at every phase, so.where()still works after it.How it works
The typed builders collect an immutable
PostgrestTableRequestand aPostgrestTableExecutorruns it. They do not wrap untyped builders, so these settings cannot just be forwarded. Instead:PostgrestRequestOptionsclass holds the headers, the retry override, the timeout and the abort signal. It is stored asPostgrestTableRequest.options, separate from the query fields, because it controls how the request is sent rather than what it asks for. Its dartdoc says an executor that does not use HTTP, such as a cache or a local store, may ignore it, and that a cache keying on the request should leave the abort signal out of the key.PostgrestHttpTableExecutorapplies the options to the final untyped builder, for both the normal path and thecount()path. Headers the user sets are applied after the builder's own, so they win.retry():enableddefaults totrue, and a count is only overridden when given. If a hand-built options object sets only a count, the client's own retry on/off setting is kept.Other changes
sdk-compliance.yaml, next to their untyped versions.AGENTS.md. It still said the typed builders wrap untyped ones, which stopped being true with feat(postgrest)!: execute typed table builders through a PostgrestTableExecutor and add SupabaseClientPlugin #1857.Tests
typed_query_test.dart, throughMockSupabaseHttpClient:count()setHeaderkeeps the filter builder, so.where()still follows itretry(enabled: false)sends the request onceretry(count:)overrides the client's retry countrequestTimeoutcancels an attempt that never answersabortSignalcancels a request already in flight, set from the query builder or from the filter buildertable_executor_test.dart: the request records the options set at every phase, and has none when nothing is set.Closes SDK-1837
Summary by CodeRabbit