Skip to content

Commit

Permalink
fix: ignore timeouts of old requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Oct 2, 2018
1 parent eea0882 commit 16b8b7c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ Previous exit stack: ${this.lastExitStack}`)
ctx.done = true

// leave a tiny bit of breathing room for after the timeout
const { shortName } = this
const { shortName, requestId } = this
const start = Date.now()
try {
await runWithTimeout(() => this.finishAsyncTasks(), {
Expand All @@ -344,6 +344,16 @@ Previous exit stack: ${this.lastExitStack}`)
}
})
} catch (err) {
if (this.requestId !== requestId) {
this.logger.error(`seems we're already on a different request`, {
error: err,
originalRequestId: requestId,
requestId,
})

return
}

const tasks = this.tasks.describe()
if (Errors.matches(err, Errors.ExecutionTimeout)) {
this.logger.error('async tasks timed out', { tasks, time: Date.now() - start })
Expand Down

0 comments on commit 16b8b7c

Please sign in to comment.