Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

getStatus() always reports attempts: 0 and uses the latest state change as createdAt

オープン 初心者向け
#54 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
api, backend

調査の方向性

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 ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

platformatic/job-queue のほかの issue

platformatic/job-queue の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。