A pooled pg Client that had a connection error (socket closed, server
restart, network blip) is marked not-queryable by node-postgres before
Prisma's adapter-pg runs the next query on it. The message
"Client has encountered a connection error and is not queryable" has no
Prisma error code, so the existing isPrismaConnectionClosed (P1017) check
does not catch it. The rejection escapes to the SportsWorker fillRegister
and tick catch blocks, logs as warn, and pages the error loop.
- Add isPgClientNotQueryable to lib/pg.ts and downgrade the error to info
in fillRegister and tick (same pattern as BIT-32810, BIT-32083).
- Add the message to isTransientDatabaseError in reporter.ts so any other
code path that lets it propagate to a generic log.error is also
suppressed (same safety-net pattern as BIT-33537 for P2037).
- Add unit tests for the new helper and the reporter filter.
Paperclip-Issue: BIT-33527
The realtime LISTEN/NOTIFY path uses pg.Client/pg.Pool directly (not
Prisma). When Postgres is completely down, Node's TCP layer throws
Error: connect ECONNREFUSED 127.0.0.1:5432 with code ECONNREFUSED.
The realtime listener already retries every 1 s (realtime.ts), but
each failed attempt was logged as 'realtime error' and reported to
errors.bitreport.pt because isTransientDatabaseError only filtered
Prisma codes (P1001/P1017) and SQLSTATE messages (57P01/57P03/53300),
not the raw Node TCP error.
Add ECONNREFUSED to the transient filter so a completely unreachable
Postgres does not trip the Error Loop with one-off incidents from
every realtime reconnect attempt.
Paperclip-Issue: BIT-33524
dbConnectionBudget reserved room for an API deploy overlap (apiReloadOverlap,
BIT-31550) but not for a worker deploy overlap. PM2 startOrReload on the
fork-mode photoreport-worker starts the new process before the old one finishes
its 25 s drain, so both Prisma pools and both broadcasters are open at once.
With defaults that is 2 * (47 + 1) + 26 = 122 > 100 max_connections, tipping
Postgres into error 53300 "sorry, too many clients already".
Add workerReloadOverlap (default 1) that divides the remaining budget by the
number of concurrent workers, so the total stays under max_connections even
during a reload. The worker's Prisma pool drops from 47 to 23 with defaults —
enough for the concurrent jobs the capacity planner sizes, and the headroom
and ad-hoc connection margin are preserved.
Paperclip-Issue: BIT-33530
The /health endpoint ran db.$queryRaw`SELECT 1` with no error handling.
When PostgreSQL hits max_connections (error 53300), the query threw
PrismaClientKnownRequestError, the error handler logged it as 'unhandled
error', and the reporter sent it to errors.bitreport.pt — creating an
error loop of one-off incidents from every health check.
Two fixes:
- /health now catches DB failures and returns 503 { status: 'degraded' }
instead of throwing, so a connection-starved health check degrades
gracefully rather than generating an error report.
- isTransientDatabaseError now filters 53300 (pool exhaustion) alongside
the existing 57P01/57P03/P1001/P1017 filters, so even if a 53300 surfaces
through another code path it does not trip the error loop.
Paperclip-Issue: BIT-33548
One different frame goes to each export, a short burst rotates so every total can still be met, and a destination can share that same frame or take the camera original.
Race condition: between the desktop rendering a FAILED delivery row and the
user clicking "Repetir", the autopilot/queue worker can requeue, retry, or
retract the item. The retry endpoint's updateMany (where status=FAILED)
matched zero rows and threw notFound("failed_item_not_found") -> 404, and
the frontend promise had no .catch -> unhandledrejection -> error loop.
API: when the item no longer matches FAILED, fetch it; if it exists return
its current state (200, idempotent), only 404 when the row is gone.
Frontend: add a rejection handler that reloads the list so a stale FAILED
row refreshes instead of becoming an unhandled rejection.
Paperclip-BIT-33418
The recorded cut is refused so the player stays whole, and the scale is what still narrows the frame. The gallery tests get a longer budget now that each frame is actually planned.
Paperclip-Issue: BIT-33293
The suite keeps a 600 px JPEG so it does not time out, and the planner reads 6000×4000. That clears the delivery floor, so focus still ranks a burst and a learnt crop stays tighter. Those names were used before they existed.
Paperclip-Issue: BIT-33293
A buyer can still place the order. It stays unpaid until an admin records money collected out of band, and that admin is then responsible for delivering the work. No invoice goes out while invoicing is off.
A single figure with empty floor — someone walking, a suitcase beside them — is the subject. The crop keeps the body and what they carry. A conversation, a distant figure, and a frame that is already full stay as shot.
A crop that only clears minLongEdge / the 3000 px floor is treated as a bad
read: leave the photograph as shot and down-rank that frame in the burst.
Learning from corrections already runs; the rules spell that out.
Soft/OOF stay out of the contest frame, lead room and edge clutter
steer the crop, wide-end zoom only levels, R1 roll feeds straighten
without chopping the subject, and bursts prefer a clear sharp face.
A tight crop was dropping a ball held out to the side and a second player, and a learnt cut could chop a body the frame had kept. Reportage stays open, open eyes win a sequence, and a Canon file that still has the camera level uses that roll. The library menu, sort, and event-day folder go out with the same change.
The cup is FPF (not Liga Portugal); without it the event picker only showed handball. Also fix kick-off parsing when day and time are stuck together in the HTML.
A database restart surfaces 57P01/57P03/P1001/P1017 through every code path
that touches Prisma during the brief outage. The per-call-site guards in
lib/pg.ts (BIT-32448–BIT-32475) cover the hot paths (syncEventSquads, rematch,
takeOffFutureGames, linkStoredSquads) but 12 more paths logged the error and
tripped the Error Loop with one-off incidents. Add a global filter in
ErrorReporter.reportError that skips transient DB errors before they reach
errors.bitreport.pt. Call-site guards that need to stop a batch or retry are
unaffected — they still catch the error first. The log line still reaches the
console; only the hub report is suppressed.
Paperclip-Issue: BIT-32490
Paperclip-Cluster: fdbb0d3da1af
PostgreSQL error 57P01 (terminating connection due to administrator command)
is emitted as an 'error' event on the pg.Pool when an idle pooled client is
killed. Both attachRealtime (API) and createRemoteBroadcaster (ingest worker)
created pools without an 'error' listener, so Node treated it as an
uncaughtException and crashed the process. Add pool.on('error') handlers that
forward to onError (and skip noise during shutdown), mirroring the existing
client.on('error') reconnection logic.
Paperclip-Issue: BIT-32447
Paperclip-Cluster: 52b3174b839d
With «Só as melhores», FPA (rest) only got the 2nd frame of gallery moments.
Aquecimento, Betclic ads and people-without-ball picks never left the window
because delivery only iterated curated chosen ids. Rest now also gets
restBeside for each closed window, including warm-up (−1).
The error hub fingerprints a bare \"TypeError: fetch failed\" with no
frame (native undici errors don't point into our code) by component
and message shape alone — every unwrapped fetch call site in the same
component collapses into one indistinguishable ERRSIG. Fixing the
desktop download route (PR #133) didn't stop this ticket from
reopening, because shop/stripe.ts's createCheckout()/call() (Stripe
Checkout + Connect) and invoicing/invoicexpress.ts's call() also threw
the native fetch error straight through to callers/routes with no
wrapping, unlike every other network client in apps/api (zerozero,
Nextcloud, VIES, calendar ICS).
Wraps both call sites in try/catch and rethrows a StripeError/
InvoicingError (status 0, descriptive message) on network failure —
same pattern Nextcloud's CloudClient and calendar's download() already
use. Gives future occurrences their own frame and fingerprint instead
of colliding into this one.
Paperclip-Agent: José Alves (urlKey jos-alves; id 11179220-3cec-4f0f-880d-2771ff64fce8)
Paperclip-Issue: BIT-31961
Paperclip-Run: 36170d99-50b2-4583-ae8e-ce8cfc898189
facesOf() called storage.personUrl(), but signed URLs live on UrlSigner, not
LocalStorage — a typecheck break that blocks ci/typescript on every PR.
Threaded SportsDeps.signer through app.ts, worker.ts and the tests that
construct SportsService directly.
saveM19Friendlies()'s upsert never set lastIngestAt, so refreshDue() saw the
FPA group as always due and refetched everything on every call instead of
respecting the six-hour cache.
Also updates two sports.test.ts assertions (15 vs 16 competitions, and
externalId 228107's shirt number) that were written before the M19-AMIG
youth friendlies and verified Caminha match-report numbers landed.
The crop-geometry refactor moved the area→linear sqrt conversion into
cropBiasOf but left two learning.ts test expectations on the old
area-ratio values, and a FoldedCrop.x0/.x1/.y0/.y1 access that no
longer exists now that FoldedCrop is { rect, angle } (silently
NaN -> null through the JSON round-trip, collapsing the learnt crop
factor to null).
In faces/service.ts, the conflicting-number score penalty required
read.votes >= 2, but majorityNumber() already only returns a result
once it has a real majority -- for a single-face group votes is
always 1, so the penalty could never fire.
The match calendar left Local and Cidade empty. The ground comes from each federation (Liga team/info, UEFA, EHF, FPA) and is stored separately from the town, then copied onto the event when the match is chosen.
The number path replaced a recognised face whenever the stored number did not match, so the player vanished on the photo where both face and number were visible. Face plus number plus kit colour is now the strongest score, and the number only names someone when the face itself is not sure.
A clear shirt named every face that read that number, so two different faces both became the same player. Face plus number stays the strongest guess; the kit of a trusted teammate decides the team; a second dissimilar face loses the name.
A detected face with a clear shorts number and no similar person was left unnamed
when the face path won by default. Clear readings now drive the suggestion.
Right-click no longer opens the webview image menu — pick, reject, IPTC, remove, etc.
Apply Lightroom/Photo Mechanic soft-crop changes on local files as develop
crops, and learn centre/scale/angle (including a looser frame) from both
external and in-app corrections so the next autopilot plans match.
A few percent of score was treated as a tie and the earlier frame won, so a sequence kept its first shot. Shirt numbers come from the match report so the next squad sync does not wipe them.
Recent FPA posts supply the next youth camp, so a call-up is not a one-off list. Tonight's Portugal–Spain under-19 game can be picked, and Cloud M19 delivers it under Seleções Nacionais/M19.
saveHeadshot threw past its callers whenever sharp couldn't decode the
fetched bytes (corrupt/truncated source, or a non-image body). The
catch in personFromFpaAssociate/personFromFpaLicence just logged and
moved on, but referenceKey stayed null, so the same bad photo was
refetched and re-thrown on every weekly FPA refresh forever.
Mark the person's referenceStatus FAILED when sharp can't decode the
downloaded bytes, and skip those people on later refreshes — a decode
failure is permanent for that URL, unlike a transient fetch error.
National matches from eurohandball.com become pickable events. A training
can take those teams without becoming the match. Ingest stays two hours
before kick-off.
National games use linked plantéis for face suggestions; Portugal/Switzerland
pull nominated numbers and res.ehf.eu headshots from eurohandball.com, keeping
FPA CIPAs for Portuguese athletes.