diff --git a/package.json b/package.json index 1d77c7b7..33eb2c90 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sqs-consumer", - "version": "5.5.0", + "version": "5.5.1", "description": "Build SQS-based Node applications without the boilerplate", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/consumer.ts b/src/consumer.ts index 1b941730..5d91f0d6 100644 --- a/src/consumer.ts +++ b/src/consumer.ts @@ -203,8 +203,8 @@ export class Consumer extends EventEmitter { let heartbeat; try { if (this.heartbeatInterval) { - heartbeat = this.startHeartbeat(async (elapsedSeconds) => { - return this.changeVisabilityTimeout(message, elapsedSeconds + this.visibilityTimeout); + heartbeat = this.startHeartbeat(async () => { + return this.changeVisabilityTimeout(message, this.visibilityTimeout); }); } await this.executeHandler(message); @@ -338,8 +338,8 @@ export class Consumer extends EventEmitter { let heartbeat; try { if (this.heartbeatInterval) { - heartbeat = this.startHeartbeat(async (elapsedSeconds) => { - return this.changeVisabilityTimeoutBatch(messages, elapsedSeconds + this.visibilityTimeout); + heartbeat = this.startHeartbeat(async () => { + return this.changeVisabilityTimeoutBatch(messages, this.visibilityTimeout); }); } await this.executeBatchHandler(messages); @@ -405,11 +405,9 @@ export class Consumer extends EventEmitter { } } - private startHeartbeat(heartbeatFn: (elapsedSeconds: number) => void): NodeJS.Timeout { - const startTime = Date.now(); + private startHeartbeat(heartbeatFn: () => void): NodeJS.Timeout { return setInterval(() => { - const elapsedSeconds = Math.ceil((Date.now() - startTime) / 1000); - heartbeatFn(elapsedSeconds); + heartbeatFn(); }, this.heartbeatInterval * 1000); } }