Guard realtime NOTIFY publishers so library() is a no-op after close(), and drain in-flight queries before pool.end().
Suppress the known Cannot use a pool after calling end on the pool race (ERRSIG 5282eca99746 / ERRCLUSTER a49a664d04ee) instead of reporting it.
Regression test covers publish-after-close on createRemoteBroadcaster.
Root cause
apps/api/src/realtime.ts fire-and-forget pool.query(pg_notify…) can still run while the worker/API calls broadcaster.close() → pool.end() during SIGTERM/restart.
CI: pnpm --filter @photoreport/api test realtime (needs DATABASE_URL_TEST)
After merge + deploy to /srv/photoreport, confirm ERRCLUSTER quiet
Paperclip-Issue: BIT-31177
## Summary
- Guard realtime NOTIFY publishers so `library()` is a no-op after `close()`, and drain in-flight queries before `pool.end()`.
- Suppress the known `Cannot use a pool after calling end on the pool` race (ERRSIG `5282eca99746` / ERRCLUSTER `a49a664d04ee`) instead of reporting it.
- Regression test covers publish-after-close on `createRemoteBroadcaster`.
## Root cause
`apps/api/src/realtime.ts` fire-and-forget `pool.query(pg_notify…)` can still run while the worker/API calls `broadcaster.close()` → `pool.end()` during SIGTERM/restart.
## Test plan
- [x] Minimal pg repro: unguarded query-after-end reproduces the exact message; guarded publisher reports 0 errors
- [ ] CI: `pnpm --filter @photoreport/api test realtime` (needs `DATABASE_URL_TEST`)
- [ ] After merge + deploy to `/srv/photoreport`, confirm ERRCLUSTER quiet
Paperclip-Issue: BIT-31177
Worker/API shutdown raced fire-and-forget NOTIFY queries, surfacing
"Cannot use a pool after calling end on the pool" (ERRSIG 5282eca99746).
Paperclip-Agent: Bug Squasher (urlKey bug-squasher; id 4669adc7-6368-43ef-bf27-5a601a6b7b83)
Paperclip-Issue: BIT-31177
Paperclip-Run: a5628443-aab8-4d4b-b0c5-089598292667
spark
merged commit 6bd78762dc into main2026-10-14 23:30:14 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
library()is a no-op afterclose(), and drain in-flight queries beforepool.end().Cannot use a pool after calling end on the poolrace (ERRSIG5282eca99746/ ERRCLUSTERa49a664d04ee) instead of reporting it.createRemoteBroadcaster.Root cause
apps/api/src/realtime.tsfire-and-forgetpool.query(pg_notify…)can still run while the worker/API callsbroadcaster.close()→pool.end()during SIGTERM/restart.Test plan
pnpm --filter @photoreport/api test realtime(needsDATABASE_URL_TEST)/srv/photoreport, confirm ERRCLUSTER quietPaperclip-Issue: BIT-31177