The error loop reported PrismaClientKnownRequestErrorP1017 ("Server has closed the connection.") from linkSquadPerson → person.findFirst (apps/api/src/sports/service.ts).
retryOnConnectionClosed (BIT-32460) already retries syncEventSquadsNow once on a fresh client. When the server keeps closing the pool (a restart or pg_terminate_backend tearing through clients), the second attempt fails the same way and the rejection escaped the syncEventSquads catch — which only matched isPrismaServerUnreachable (P1001/57P03). The resulting warn paged the error loop for a transient blip.
Fix
Treat a P1017 that survives the retry like the existing unreachable handling (BIT-32463/BIT-32470/BIT-32471): log at info and stop the sync, letting the next scheduled call retry once the pool is stable.
Tests
New p1017 helper + syncEventSquads downgrades a P1017 server-closed connection that exhausts the retry (BIT-32475) test (asserts info log database connection closed, no warn, zero result).
pnpm --filter @photoreport/api typecheck green.
Unit tests (src/lib/pg.test.ts, src/sports/service.test.ts) green: 26 passed.
## Summary
The error loop reported `PrismaClientKnownRequestError` **P1017** ("Server has closed the connection.") from `linkSquadPerson` → `person.findFirst` (`apps/api/src/sports/service.ts`).
`retryOnConnectionClosed` (BIT-32460) already retries `syncEventSquadsNow` once on a fresh client. When the server keeps closing the pool (a restart or `pg_terminate_backend` tearing through clients), the second attempt fails the same way and the rejection escaped the `syncEventSquads` catch — which only matched `isPrismaServerUnreachable` (P1001/57P03). The resulting `warn` paged the error loop for a transient blip.
## Fix
Treat a P1017 that survives the retry like the existing unreachable handling (BIT-32463/BIT-32470/BIT-32471): log at `info` and stop the sync, letting the next scheduled call retry once the pool is stable.
## Tests
- New `p1017` helper + `syncEventSquads downgrades a P1017 server-closed connection that exhausts the retry (BIT-32475)` test (asserts info log `database connection closed`, no warn, zero result).
- `pnpm --filter @photoreport/api typecheck` green.
- Unit tests (`src/lib/pg.test.ts`, `src/sports/service.test.ts`) green: 26 passed.
Paperclip-Issue: BIT-32475
Paperclip-Cluster: 792bb5de9fcb
The error loop reported PrismaClientKnownRequestError P1017 ("Server has
closed the connection.") from linkSquadPerson -> person.findFirst.
retryOnConnectionClosed (BIT-32460) already retries syncEventSquadsNow once
on a fresh client; when the server keeps closing the pool (a restart or
pg_terminate_backend tearing through clients), the second attempt fails the
same way and the rejection escaped the syncEventSquads catch, which only
matched isPrismaServerUnreachable (P1001/57P03). The warn paged the error
loop for a transient blip.
Treat a P1017 that survives the retry like the existing unreachable
handling: log at info and stop the sync, letting the next scheduled call
retry once the pool is stable. Mirrors BIT-32463/BIT-32470/BIT-32471.
Paperclip-Issue: BIT-32475
Paperclip-Cluster: 792bb5de9fcb
spark
merged commit 5b80e614f6 into main2026-11-18 22:35:46 +00: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
The error loop reported
PrismaClientKnownRequestErrorP1017 ("Server has closed the connection.") fromlinkSquadPerson→person.findFirst(apps/api/src/sports/service.ts).retryOnConnectionClosed(BIT-32460) already retriessyncEventSquadsNowonce on a fresh client. When the server keeps closing the pool (a restart orpg_terminate_backendtearing through clients), the second attempt fails the same way and the rejection escaped thesyncEventSquadscatch — which only matchedisPrismaServerUnreachable(P1001/57P03). The resultingwarnpaged the error loop for a transient blip.Fix
Treat a P1017 that survives the retry like the existing unreachable handling (BIT-32463/BIT-32470/BIT-32471): log at
infoand stop the sync, letting the next scheduled call retry once the pool is stable.Tests
p1017helper +syncEventSquads downgrades a P1017 server-closed connection that exhausts the retry (BIT-32475)test (asserts info logdatabase connection closed, no warn, zero result).pnpm --filter @photoreport/api typecheckgreen.src/lib/pg.test.ts,src/sports/service.test.ts) green: 26 passed.Paperclip-Issue: BIT-32475
Paperclip-Cluster: 792bb5de9fcb
The error loop reported PrismaClientKnownRequestError P1017 ("Server has closed the connection.") from linkSquadPerson -> person.findFirst. retryOnConnectionClosed (BIT-32460) already retries syncEventSquadsNow once on a fresh client; when the server keeps closing the pool (a restart or pg_terminate_backend tearing through clients), the second attempt fails the same way and the rejection escaped the syncEventSquads catch, which only matched isPrismaServerUnreachable (P1001/57P03). The warn paged the error loop for a transient blip. Treat a P1017 that survives the retry like the existing unreachable handling: log at info and stop the sync, letting the next scheduled call retry once the pool is stable. Mirrors BIT-32463/BIT-32470/BIT-32471. Paperclip-Issue: BIT-32475 Paperclip-Cluster: 792bb5de9fcb