Skip to content

fix(cli): wait for postgrest after local db reset (CLI-3162) - #7716

Merged
7ttp merged 2 commits into
developfrom
7ttp/cli-3162-local-db-reset-on-cli-320-can-exit-before
Nov 19, 2026
Merged

7ttp merged 2 commits into
developfrom
7ttp/cli-3162-local-db-reset-on-cli-320-can-exit-before

Conversation

@7ttp

@7ttp 7ttp commented Nov 19, 2026

Copy link
Copy Markdown
Member

TL;DR

the first Data API request after a local db reset now sees the reset schema instead of a 503, a 400 or the old schema

whats broken?

db reset recreates the database while PostgREST keeps running, so PostgREST drops its connection and reconnects after a short backoff, missing the schema reload that migrations send

reset never waited for it, so it could print Finished supabase db reset. while PostgREST was still offline or serving the old schema

now fixed by:

restarting PostgREST once migrations and seeds are done so it loads the reset schema, reloading the API gateway to route to it, then waiting until PostgREST reports ready through the gateway

a failure in this step only prints a warning and the reset still succeeds. the [experimental] stack path is unchanged

visual rep
%%{init: {"theme": "base", "themeVariables": {"background": "transparent", "mainBkg": "transparent", "primaryColor": "transparent", "secondaryColor": "transparent", "tertiaryColor": "transparent", "actorBkg": "transparent", "noteBkgColor": "transparent", "labelBoxBkgColor": "transparent", "activationBkgColor": "transparent", "primaryBorderColor": "#8b949e", "actorBorder": "#8b949e", "actorLineColor": "#8b949e", "noteBorderColor": "#8b949e", "labelBoxBorderColor": "#8b949e", "lineColor": "#8b949e", "signalColor": "#8b949e", "textColor": "#8b949e", "actorTextColor": "#8b949e", "signalTextColor": "#8b949e", "noteTextColor": "#8b949e", "labelTextColor": "#8b949e", "loopTextColor": "#8b949e"}, "sequence": {"mirrorActors": false}}}%%
sequenceDiagram
    participant cli as CLI
    participant db as database
    participant rest as PostgREST
    participant gw as API gateway
    participant app as your app

    alt before
        Note right of cli: supabase db reset
        cli->>db: recreate
        db--xrest: connection dropped
        Note right of rest: reconnects in 1s, 2s, …
        cli->>db: migrations + seed
        db--xrest: reload notice missed while reconnecting
        Note right of cli: Finished supabase db reset.
        app->>gw: GET /rest/v1/
        gw->>rest: forward
        rest-->>gw: 503, 400 or old schema
        gw-->>app: request fails
    else now
        Note right of cli: supabase db reset
        cli->>db: recreate, migrations + seed
        Note right of rest: restarted
        rest->>db: load reset schema
        cli->>gw: reload
        loop every 1s until ready
            cli->>gw: ready?
            gw-->>cli: 200
        end
        Note right of cli: Finished supabase db reset.
        app->>gw: GET /rest/v1/
        gw->>rest: forward
        rest-->>gw: 200, reset schema
        gw-->>app: new column is there
    end
Loading

ref:

@7ttp 7ttp self-assigned this Nov 19, 2026
@7ttp
7ttp requested a review from a team as a code owner November 19, 2026 12:09
@7ttp
7ttp requested a review from Coly010 November 19, 2026 12:09
@github-actions

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit 92735fe against develop at 5884942 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 438 ms 400 ms no real change (-9%, within normal variation)
supabase --help help 457 ms 428 ms no real change (-6%, within normal variation)
supabase init init 398 ms 407 ms no real change
supabase migration new bench migration-new 403 ms 401 ms no real change
supabase config convert config-convert 440 ms 488 ms no real change (+11%, within normal variation)
supabase config validate config-validate 431 ms 447 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 449 ms 440 ms no real change
supabase projects list projects-list 383 ms 377 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 419 ms 434 ms no real change

API calls: unchanged for all 9 commands.

Binary size: 135.2 MB, down 4.0 KB from 135.3 MB.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 306-676 ms 362-508 ms -38 ms (-9%) within noise
supabase --help help 389-695 ms 342-499 ms -29 ms (-6%) within noise
supabase init init 381-510 ms 336-472 ms +9 ms (+2%) within noise
supabase migration new bench migration-new 368-495 ms 346-796 ms -1 ms (0%) within noise
supabase config convert config-convert 375-567 ms 377-655 ms +48 ms (+11%) within noise
supabase config validate config-validate 349-538 ms 282-678 ms +16 ms (+4%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 399-677 ms 379-509 ms -9 ms (-2%) within noise
supabase projects list projects-list 303-509 ms 294-570 ms -6 ms (-2%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 384-614 ms 363-511 ms +15 ms (+4%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

github-actions[bot]

This comment was marked as resolved.

@Coly010 Coly010 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@7ttp
7ttp added this pull request to the merge queue Nov 19, 2026
Merged via the queue into develop with commit 61e1433 Nov 19, 2026
69 checks passed
@7ttp
7ttp deleted the 7ttp/cli-3162-local-db-reset-on-cli-320-can-exit-before branch November 19, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local db reset on CLI 3.2.0 can exit before PostgREST is ready

2 participants