This repository was archived by the owner on Aug 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 11# elastic-apm-http-client changelog
22
3+ ## Unreleased
4+
5+ - Fix an issue when running in a Lambda function, where a missing or erroring
6+ APM Lambda extension could result in apmclient back-off such that (a) the
7+ end-of-lambda-invocation signaling (` ?flushed=true ` ) would not happen and
8+ (b) premature "beforeExit" event could result in the Lambda Runtime
9+ responding ` null ` before the Lambda function could respond
10+ (https://github.com/elastic/apm-agent-nodejs/issues/1831 ).
11+
312## v11.0.0
413
514- Add support for coordinating data flushing in an AWS Lambda environment. The
Original file line number Diff line number Diff line change @@ -781,9 +781,18 @@ Client.prototype._destroy = function (err, cb) {
781781// Return the appropriate backoff delay (in milliseconds) before a next possible
782782// request to APM server.
783783// Spec: https://github.com/elastic/apm/blob/main/specs/agents/transport.md#transport-errors
784+ //
785+ // In a Lambda environment, a backoff delay can be harmful: The backoff
786+ // setTimeout is unref'd, to not hold the process open. A subsequent Lambda
787+ // function invocation during that timer will result in no active handles and
788+ // a process "beforeExit" event. That event is interpreted by the Lambda Runtime
789+ // as "the Lambda function callback was never called", and it terminates the
790+ // function and responds with `null`. The solution is to never backoff in a
791+ // Lambda environment -- we expect and assume the Lambda extension is working,
792+ // and pass responsibility for backoff to the extension.
784793Client . prototype . _getBackoffDelay = function ( isErr ) {
785794 let reconnectCount = this . _backoffReconnectCount
786- if ( isErr ) {
795+ if ( isErr && ! isLambdaExecutionEnvironment ) {
787796 this . _backoffReconnectCount ++
788797 } else {
789798 this . _backoffReconnectCount = 0
You can’t perform that action at this time.
0 commit comments