sql-pg: pool is not closed when the "SELECT 1" readiness probe fails in PgClient.make
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- postgresql, typescript
- Domain
- database
Research direction
Start in packages/sql/pg/src/PgClient.ts at PgClient.make and trace the pool creation, SELECT 1 acquisition, and release finalizer. Verify the readiness-probe failure path and ensure the constructed pool is ended there while preserving the existing successful-acquisition cleanup behavior.
Written by the indexing model from the issue text.
Description
Package
@effect/sql-pg 0.53.0 (the same structure is present in the v4 sources at packages/sql/pg/src/PgClient.ts).
Description
In PgClient.make, the pg.Pool is constructed before the acquisition effect:
const pool = new Pg.Pool({ ... })
pool.on("error", () => {})
yield* Effect.acquireRelease(
Effect.tryPromise({
try: () => pool.query("SELECT 1"),
catch: (cause) => new SqlError({ ... })
}),
() => Effect.promise(() => pool.end()).pipe(...)
).pipe(...)
Per Effect.acquireRelease semantics, the release finalizer is registered only after a successful acquire — so when the SELECT 1 readiness probe fails, pool.end() is never called and the already-constructed pool object is orphaned.
Impact
Small in practice (pg pools are lazy — a pool that never acquired a client holds no sockets or timers, so the orphaned object is garbage-collectable), but:
- callers that retry a failed layer build (e.g. a self-healing wrapper around
ManagedRuntimethat replaces the runtime after a failed build) accumulate pool instances across attempts, - the
pool.end()finalizer signals the intent to always release the pool, so a failed probe silently violating that contract is surprising.
Suggested fix
End the pool when the probe fails, e.g.:
Effect.acquireRelease(
Effect.tryPromise({
try: () => pool.query("SELECT 1"),
catch: (cause) => new SqlError({ ... })
}).pipe(Effect.tapErrorCause(() => Effect.promise(() => pool.end()))),
() => ...
)
or construct the pool inside the acquire effect.
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 808
- Avg merge
- 10h 36m
- Merged PRs (30d)
- 449
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Effect-TS/effect
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Effect-TS/effect#8881 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
Effect-TS/effect#8863 · 1 comment ·
Maintainers usually reply within 1 day
-
BrowserWorkerRunner: port finalizer throws when the worker global has no close() (Bun)Possibly taken @santiago-ramos-02 claimed this 6 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Effect-TS/effect#8635 · 3 comments ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Effect-TS/effect#8101 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
Effect-TS/effect#8860 · 1 reaction ·
Maintainers usually reply within 1 day
All issues in Effect-TS/effect
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
[Bug] remember() with special characters in namespace hangs until timeout instead of returning 400Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
MystenLabs/MemWal#1133 · 1 comment ·
Maintainers usually reply within 1 day
-
bug user-priority/P2
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Discover carries headerEdges that nothing reads since #1914 moved E0507/E0517 to the compiler graphOpentech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day