getStatus() always reports attempts: 0 and uses the latest state change as createdAt
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
調査の方向性
src/producer.ts の Producer.getStatus() から始め、リンクされた行と再現手順を入口として使用します。提供されている queue の例を実行し、そのステータスを README の例と比較します。完了とは、完了済みのジョブが実際の試行回数を報告し、enqueue 時に設定された createdAt の値を保持することです。
索引モデルが issue の本文から書いたものです。
説明
queue.getStatus(id) always returns attempts: 0, and createdAt is the time of the job's latest state change rather than when it was created. The README's example shows attempts: 1 for a completed job.
Reproduction
@platformatic/[email protected] (also on main):
import { MemoryStorage, Queue } from '@platformatic/job-queue'
import { setTimeout as sleep } from 'node:timers/promises'
const storage = new MemoryStorage()
const queue = new Queue({ storage })
queue.execute(async job => {
await sleep(500)
if (job.attempts === 1) throw new Error('first attempt fails')
return 'ok'
})
await queue.start()
const enqueuedAt = Date.now()
await queue.enqueueAndWait('job-1', {}, { maxAttempts: 2 })
const status = await queue.getStatus('job-1')
console.log(status)
console.log('attempts reported:', status.attempts, '(the job ran 2 times)')
console.log('createdAt - enqueue time:', status.createdAt - enqueuedAt, 'ms')
await queue.stop()
await storage.disconnect()
Output:
{
id: 'job-1',
state: 'completed',
createdAt: 1790375360171,
attempts: 0,
result: 'ok'
}
attempts reported: 0 (the job ran 2 times)
createdAt - enqueue time: 1004 ms
Cause
Producer.getStatus() hardcodes attempts: 0 (producer.ts#L253) and uses the timestamp parsed from the current state string as createdAt (producer.ts#L252). Only failing: states carry an attempt count, and the timestamp is rewritten on every transition.
I'm happy to send a PR for this.
- 主要言語
- TypeScript
- スター
- 370
- フォーク
- 11
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
platformatic/job-queue のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
platformatic/job-queue#53 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
platformatic/job-queue#52 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
platformatic/job-queue#51 ·
platformatic/job-queue の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
grafana/profiles-drilldown#1212 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
grafana/traces-drilldown#980 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
openremote/openremote#3487 · コメント 1 件 ·
-
triage:needs-human
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
garrytan/gbrain#7635 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
coollabsio/jean#867 ·
メンテナーはふだん 1 日以内に返信