getStatus() always reports attempts: 0 and uses the latest state change as createdAt
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start in src/producer.ts at Producer.getStatus(), using the linked lines and the reproduction as the entry points. Run the provided queue example and compare its status with the README example; done means completed jobs report their actual attempt count and retain the enqueue-time createdAt value.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 370
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from platformatic/job-queue
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
platformatic/job-queue#53 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
platformatic/job-queue#52 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
platformatic/job-queue#51 ·
All issues in platformatic/job-queue
Similar issues
-
[good first issue, hacktoberfest] 🏯 Hacktoberfest Task - Add new Japan Fact 898 (good-first-issue)Opencommunity first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 86/100
lingdojo/kana-dojo#33145 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
code-yeongyu/senpi#4278 ·
Maintainers usually reply within 1 day
-
[Bug] Activity | The activity list ignores taskIds and returns the activities of every taskPossibly taken @NdekoCode claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ever-co/ever-gauzy#11469 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
griffinwork40/agent-afk#4408 ·
Maintainers usually reply within 1 day