Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#54 0 comments 0 reactions 0 assignees View on GitHub

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
Domain
api, backend

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from platformatic/job-queue

All issues in platformatic/job-queue

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.