Skip to content

test: secret list command - #312

Merged
soedirgo merged 3 commits into
mainfrom
test-secret
Jul 25, 2022
Merged

test: secret list command#312
soedirgo merged 3 commits into
mainfrom
test-secret

Conversation

@sweatybridge

@sweatybridge sweatybridge commented Jul 25, 2022

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

unit test, refactor

What is the current behavior?

Please link any relevant issues here.

What is the new behavior?

  • starts moving static file paths to utils package
  • secret list: 85.7% coverage

Additional context

Add any other context or screenshots.

@sweatybridge
sweatybridge requested a review from soedirgo as a code owner July 25, 2022 03:25
@soedirgo
soedirgo merged commit af6403c into main Jul 25, 2022
@soedirgo
soedirgo deleted the test-secret branch July 25, 2022 03:40
@github-actions

github-actions Bot commented Aug 1, 2022

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.32.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

TFSebben pushed a commit to TFSebben/supabase_cli that referenced this pull request Jul 3, 2026
supabase#5714)

Fixes `supabase db schema declarative sync --experimental` (and other
pg-delta flows) hanging indefinitely at 0% CPU after the shadow-database
work completes.

Closes supabase/pg-toolbelt#312

There are two independent causes, both needed to unblock the command:

## 1. The Edge Runtime worker never exits

The pg-delta scripts run in a one-shot Edge Runtime container and rely
on the event loop draining for the worker to be destroyed and the
container to stop. The catalog-export script opens a real connection
pool (`createManagedPool`); when a keepalive handle stays registered
after `close()` resolves, the worker never exits, so the container never
stops. Only the error path force-closed the loop (`throw new
Error("")`); the success path did not.

Fix: force-close the event loop on the **success** path of every
pg-delta script once its output is flushed, so the worker is torn down
deterministically:

- `templates/pgdelta_catalog_export.ts` — catalog snapshot (the path
reported in supabase#312)
- `templates/pgdelta.ts` — diff SOURCE→TARGET
- `templates/pgdelta_declarative_export.ts` — declarative file export
- `templates/pgdelta_declarative_apply.ts` — apply declarative schema
- the inline catalog-export script in `internal/db/pgcache/cache.go` —
the `db start` / `db push` migrations-catalog cache path

The byte-for-byte embedded copies in `legacy-pgdelta.deno-templates.ts`
are kept in sync.

## 2. Following the container log stream hangs under podman

With the worker now exiting, the container stops — but the parent still
hung for podman users. A goroutine dump on the stuck `__catalog`
subprocess showed the block in `stdcopy.StdCopy` reading the
`Follow:true` Docker log stream (`DockerStreamLogs`): podman's
`/containers/<id>/logs?follow` endpoint does not close when the
container stops, so the read never gets EOF and blocks forever. Docker
closes it, which is why this only reproduced on podman.

Fix: run the bounded edge-runtime scripts via a new
`DockerRunOnceWaitWithConfig`, which detects completion by polling
`ContainerInspect` (reliable on podman) and then reads the buffered logs
**without following**. The shared `DockerStreamLogs` (live streaming for
`functions serve`) and `DockerRunOnceWithConfig` (large streaming output
for `db dump`) are intentionally left unchanged, so only the bounded
pg-delta/edge-runtime path changes behaviour.

Regression coverage is added for both: guard tests asserting each
script's success path force-closes, and a test pinning that the runner
reads captured output and maps the inspected exit code without following
the log stream.

https://claude.ai/code/session_01XbxecW4DVmwgQB1YX321K3

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants