From 16b8b7ca12a427a272db5b2c2afa24313dd96072 Mon Sep 17 00:00:00 2001 From: Mark Vayngrib Date: Tue, 2 Oct 2018 11:26:19 -0400 Subject: [PATCH] fix: ignore timeouts of old requests --- src/lambda.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lambda.ts b/src/lambda.ts index d15552766..acb8d8188 100644 --- a/src/lambda.ts +++ b/src/lambda.ts @@ -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(), { @@ -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 })