Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

elastic-apm-http-client

Package Overview
Dependencies
Maintainers
3
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elastic-apm-http-client - npm Package Compare versions

Comparing version 9.7.0 to 9.7.1

7

CHANGELOG.md
# elastic-apm-http-client changelog
## v9.7.1
- Fix to ensure the `client.flush(cb)` callback is called in the (expected to
be rare) case where there are no active handles -- i.e., the process is
exiting.
([#150](https://github.com/elastic/apm-nodejs-http-client/issues/150))
## v9.7.0

@@ -4,0 +11,0 @@

43

index.js

@@ -49,4 +49,3 @@ 'use strict'

}
client._log.trace('auto-end client beforeExit')
client.end()
client._gracefulExit()
})

@@ -78,2 +77,3 @@ })

this._backoffReconnectCount = 0
this._intakeRequestGracefulExitFn = null // set in makeIntakeRequest

@@ -556,2 +556,19 @@ // Internal runtime stats for developer debugging/tuning.

// A handler that can be called on process "beforeExit" to attempt quick and
// orderly shutdown of the client. It attempts to ensure that the current
// active intake API request to APM server is completed quickly.
Client.prototype._gracefulExit = function () {
this._log.trace('_gracefulExit')
if (this._intakeRequestGracefulExitFn) {
this._intakeRequestGracefulExitFn()
}
// Calling _ref here, instead of relying on the _ref call in `_final`,
// is necessary because `client.end()` does *not* result in the Client's
// `_final()` being called when the process is exiting.
this._ref()
this.end()
}
Client.prototype._final = function (cb) {

@@ -641,9 +658,9 @@ this._log.trace('_final')

// the process is ready to exit, the following happens:
// - The "beforeExit" handler above will call `client.end()`,
// - which calls `client._ref()` (to *hold the process open* to complete
// this request), then `_chopper.end()` to end the `gzipStream` so
// - The "beforeExit" handler above will call `client._gracefulExit()` ...
// - ... which calls `client._ref()` to *hold the process open* to
// complete this request, and `client.end()` to end the `gzipStream` so
// this request can complete soon.
// - We then expect this request to complete quickly and the process will
// then finish exiting. A subtlety is if the APM server is not responding
// then we'll wait on `intakeResTimeoutOnEnd` (by default 1s).
// then we'll wait on the shorter `intakeResTimeoutOnEnd` (by default 1s).
return function makeIntakeRequest (gzipStream, next) {

@@ -714,2 +731,3 @@ const reqId = crypto.randomBytes(16).toString('hex')

}
client._intakeRequestGracefulExitFn = null

@@ -739,2 +757,15 @@ client.sent = client._numEventsEnqueued

// Provide a function on the client for it to signal this intake request
// to gracefully shutdown, i.e. finish up quickly.
client._intakeRequestGracefulExitFn = () => {
if (intakeResTimer) {
clearTimeout(intakeResTimer)
intakeResTimer = setTimeout(() => {
completePart('intakeRes',
new Error('intake response timeout: APM server did not respond ' +
`within ${intakeResTimeoutOnEnd / 1000}s of graceful exit signal`))
}, intakeResTimeoutOnEnd).unref()
}
}
// Start the request and set its timeout.

@@ -741,0 +772,0 @@ const intakeReq = client._transport.request(client._conf.requestIntake)

2

package.json
{
"name": "elastic-apm-http-client",
"version": "9.7.0",
"version": "9.7.1",
"description": "A low-level HTTP client for communicating with the Elastic APM intake API",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc