fix(selfhost): catch unhandled pump() rejections in sqlite-queue/pg-queue#2544
Conversation
…ueue claimNext()/reclaimExpiredProcessingJobs() run outside processOne()'s own try/finally in both queue drivers, so a raw driver failure (a locked SQLite file, a dropped Postgres connection) propagated out of pump() uncaught. Every void pump() call site (kickOne/kickAll) is fire-and-forget, so this surfaced as an unhandled promise rejection — fatal when SENTRY_DSN is unset, since server.ts only installs the unhandledRejection handler when Sentry is configured. A single transient DB error could silently kill the whole self-host server. Wrap pump()'s body in a try/catch that logs and captures the failure instead of letting it propagate, matching the pattern already used throughout processOne() for job-level errors.
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-02 09:01:58 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2544 +/- ##
==========================================
+ Coverage 95.95% 95.97% +0.01%
==========================================
Files 226 228 +2
Lines 25423 25711 +288
Branches 9244 9349 +105
==========================================
+ Hits 24395 24676 +281
- Misses 417 425 +8
+ Partials 611 610 -1
🚀 New features to boost your workflow:
|
Summary
kickOne()/kickAll()insqlite-queue.ts/pg-queue.tsfirepump()via barevoid pump()with no.catch().claimNext()/reclaimExpiredProcessingJobs()run OUTSIDEprocessOne()'s own try/finally, so a raw driver failure (a locked SQLite file, a dropped Postgres connection/lock timeout) propagated out ofpump()uncaught.server.tsonly registersprocess.on('unhandledRejection', ...)whenSENTRY_DSNis set. Since Sentry is opt-in, a single transient DB error surfacing fromclaimNext()/reclaimExpiredProcessingJobs()could silently crash the entire self-host server — no metric bump, no Sentry event, no/readydegradation warning beforehand.pump()'s body in a try/catch that logs (selfhost_queue_pump_crashed) and callscaptureErrorinstead of letting the exception propagate, in both queue drivers.claimNext()query and separately on thereclaimExpiredProcessingJobs()query, in bothsqlite-queue.tsandpg-queue.ts; assertdrain()resolves cleanly (no unhandled rejection) and the failure is logged.Closes #2498.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateSafety
UI Evidencesection below — N/A, no UI changes.Notes