Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 66 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/queue",
"version": "5.17.0",
"version": "5.18.0",
"description": "The Athenna queue handler.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down
32 changes: 32 additions & 0 deletions src/drivers/AwsSqsDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,20 +387,52 @@ export class AwsSqsDriver extends Driver<SQSClient> {

AwsSqsDriver.ackedIds.delete(job.id)

const heartbeatDelay = this.calculateHeartbeatDelay()

let heartbeatTimeout: NodeJS.Timeout

const startHeartbeat = () => {
if (heartbeatDelay <= 0) {
return
}

heartbeatTimeout = setInterval(() => {
this.changeJobVisibility(
job.id,
this.msToS(this.visibilityTimeout)
).catch(() => {})
}, heartbeatDelay)
}

const stopHeartbeat = () => {
if (!heartbeatTimeout) {
return
}

clearInterval(heartbeatTimeout)
heartbeatTimeout = undefined
}

try {
startHeartbeat()

await processor({
id: job.id,
attempts: job.attempts,
data: job.data
})

stopHeartbeat()

if (!AwsSqsDriver.ackedIds.has(job.id)) {
await this.changeJobVisibility(
job.id,
this.msToS(this.noAckDelayMs + requeueJitterMs)
)
}
} catch (err) {
stopHeartbeat()

const receiveCount = Number(
job.metadata.Attributes?.ApproximateReceiveCount ?? '1'
)
Expand Down
Loading
Loading