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 1
1
# elastic-apm-http-client changelog
2
2
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
+
3
12
## v11.0.0
4
13
5
14
- 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) {
781
781
// Return the appropriate backoff delay (in milliseconds) before a next possible
782
782
// request to APM server.
783
783
// 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.
784
793
Client . prototype . _getBackoffDelay = function ( isErr ) {
785
794
let reconnectCount = this . _backoffReconnectCount
786
- if ( isErr ) {
795
+ if ( isErr && ! isLambdaExecutionEnvironment ) {
787
796
this . _backoffReconnectCount ++
788
797
} else {
789
798
this . _backoffReconnectCount = 0
You can’t perform that action at this time.
0 commit comments