Skip to content

Commit

Permalink
fix: memory leak with lambda timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Oct 6, 2022
1 parent 50b2a1a commit c9c8c14
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/lambda/LambdaFunction.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,31 +306,31 @@ export default class LambdaFunction {
this.#handlerRunner.run(this.#event, context),
...(this.#noTimeout ? [] : [this.#timeoutAndTerminate()]),
])

this.#stopExecutionTimer()

// TEMP TODO FIXME find better solution
if (!this.#handlerRunner.isDockerRunner()) {
log.notice(
`(λ: ${
this.#functionKey
}) RequestId: ${requestId} Duration: ${this.#executionTimeInMillis().toFixed(
2,
)} ms Billed Duration: ${this.#billedExecutionTimeInMillis()} ms`,
)
}
} catch (err) {
if (err instanceof LambdaTimeoutError) {
await this.#handlerRunner.cleanup()
}

throw err
}

this.#stopExecutionTimer()
} finally {
this.#status = 'IDLE'

// TEMP TODO FIXME find better solution
if (!this.#handlerRunner.isDockerRunner()) {
log.notice(
`(λ: ${
this.#functionKey
}) RequestId: ${requestId} Duration: ${this.#executionTimeInMillis().toFixed(
2,
)} ms Billed Duration: ${this.#billedExecutionTimeInMillis()} ms`,
)
this.#startIdleTimer()
}

this.#status = 'IDLE'

this.#startIdleTimer()

return result
}
}

0 comments on commit c9c8c14

Please sign in to comment.