Unhandled rejection when recording a job's outcome fails with unbatched completeJob/failJob
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 62/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- node.js, postgresql, typescript
調査の方向性
Start with the unbatched completeJob and failJob in dist/main.js, around lines 879-921, and the call sites in dist/worker.js near lines 262 and 283, where the returned promise is neither awaited nor given a rejection handler. Check withRetries in dist/lib.js, which rethrows errors without a retryable code. Reproduce by wrapping the pool client so one update or delete query rejects, then confirm the rejection reaches unhandledRejection. Done means the failure is logged with the job id and/or reported via worker:fatalError, with no unhandled rejection.
索引モデルが issue の本文から書いたものです。
説明
Summary
With the default (unbatched) completeJobBatchDelay / failJobBatchDelay of -1, the worker calls completeJob(job) and failJob(...) without awaiting them or attaching a rejection handler. If the query that records the job's outcome fails with an error that withRetries does not consider retryable, for example Error: Connection terminated unexpectedly from pg (which has no code), the rejection is unhandled. In a Node process without an unhandledRejection listener this crashes the process, and in every case worker:fatalError is not emitted and the job stays locked until its lock expires.
Steps to reproduce
- Run a worker with
run()and the default batch delays (-1), using apg.Poolwith anerrorhandler attached. - Make the connection drop (or the query reject with an error without a retryable
code) on the query that records a job's outcome: theupdate ... _private_jobs ... set last_error ...of a failing task, or thedelete from ... _private_jobs ...of a succeeding one. Wrapping the pool's client so that query rejects once withnew Error("Connection terminated unexpectedly")reproduces it deterministically. - Add a job for a task (one that throws, for the
failJobpath; one that succeeds, for thecompleteJobpath) and let the worker pick it up.
Expected results
The failure to record the outcome is handled: logged with the job id (as the batched path's error handler does) and/or reported through worker:fatalError or another event, without leaving a rejected promise unhandled.
Actual results
The rejection reaches process.on("unhandledRejection"). Without a listener, Node exits with the error. No worker:fatalError event is emitted, nothing is logged by the worker, and the job remains locked until the stale-lock reset releases it.
Additional context
- graphile-worker 0.18.0, Node 24.21, pg 8.23, PostgreSQL 18.
- In the published
dist/worker.js,failJob({...})(around line 262) andcompleteJob(job)(around line 283) are called inside atrywhosecatch (fatalError)only sees synchronous throws, so a rejected promise bypasses it. - In
dist/main.js(around lines 879-921), the unbatchedcompleteJob/failJobare plain closures overbatchCompleteJobs/batchFailJobswithwithPgClient.withRetriesand no error callback; only the batched branch passes an error handler. withRetries(dist/lib.js, around lines 365-385) retries only errors whosecodeis inRETRYABLE_ERROR_CODES, so a connection-terminated error without a code is rethrown immediately.- I searched existing issues and found nothing about this; #635 and #636 are related but concern the batched path and
runner.promise.
Possible Solution
Handle the promise returned by the unbatched completeJob / failJob in the worker, for example by attaching a rejection handler that logs the error with the job id and emits worker:fatalError (or a dedicated event), matching how the batched path reports its failures. A local patch doing completeJob(job)?.then(null, (fatalError) => logger.error(..., { fatalError })) (and the same for failJob) removes the unhandled rejection in our testing.
- 主要言語
- TypeScript
- スター
- 2.5k
- フォーク
- 134
- 平均マージ
- 16時間 24分
- マージ済み PR(30日)
- 3
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
graphile/worker のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
Task identifier cache keeps a rejected lookup forever, wedging the runner after a connection drop対応中かも @agustin18 が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Batched `completeJobs`/`failJobs` are never retried: the retry loop in `batch()` exits after the first failure対応中かも @ujjawal-yadav が 42 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
`runner.promise` resolves when the worker pool exits with an error対応中かも @Krrishkumar125 が 35 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
Write docs for local queue!対応中かも @Krrishkumar125 が 34 日前に担当しました。 オープンdocs
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
graphile/worker の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
abhigyanpatwari/GitNexus#4124 ·
メンテナーはふだん 1 日以内に返信
-
good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
laaielichter/Godotwright#250 ·
メンテナーはふだん 1 日以内に返信
-
An Antigravity tab can quote an old Assist message as the owner's words in a resumed conversationオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
Retry an empty final answer when Gemini reports MALFORMED_RESPONSE (gemini-4-hydrogen)対応中かも @waleedkadous が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
iaser-ai/ansari#444 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Manager UI logo fails to load — broken external URL対応中かも @kavindu-udara が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100