newrelic 14.2.0 → 14.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NEWS.md CHANGED
@@ -1,3 +1,26 @@
1
+ ### v14.2.1 (2026-07-09)
2
+
3
+ #### Bug fixes
4
+
5
+ * Updated `winston` instrumenting to assign `handleExceptions` to the first NrTransport to avoid registering duplicate `uncaughtException` handlers ([#4108](https://github.com/newrelic/node-newrelic/pull/4108)) ([d60a48d](https://github.com/newrelic/node-newrelic/commit/d60a48d3b9399d3a084c64cf53c3a62c7a4cab0b))
6
+ * This would create a linear memory leak because the `NrTransport` objects for loggers no longer in use, would not be freed because of the global `process.on('uncaughtException')` handler
7
+
8
+ #### Documentation
9
+
10
+ * Updated compatibility report ([#4099](https://github.com/newrelic/node-newrelic/pull/4099)) ([058fde6](https://github.com/newrelic/node-newrelic/commit/058fde6d64e3606b82875380ba51f9bc44a4b994))
11
+
12
+ #### Continuous integration
13
+
14
+ * Pinned CI npm to 11 so native versioned suites build on Node 22 ([#4114](https://github.com/newrelic/node-newrelic/pull/4114)) ([b844e94](https://github.com/newrelic/node-newrelic/commit/b844e94317e573410d96f8971308b2d1535570ca))
15
+ * Removed the 8 minute versioned shard timeout ([#4111](https://github.com/newrelic/node-newrelic/pull/4111)) ([0ef6374](https://github.com/newrelic/node-newrelic/commit/0ef63749b2739d7c7446a6b7c6d3ee80d2d360e5))
16
+ * Attempted to fix memcached CI issue again ([#4098](https://github.com/newrelic/node-newrelic/pull/4098)) ([f67fef5](https://github.com/newrelic/node-newrelic/commit/f67fef5febe71ffab853164aba06c76cd2c6c26d))
17
+ * Shard versioned tests across CI runners ([#4101](https://github.com/newrelic/node-newrelic/pull/4101)) ([1471734](https://github.com/newrelic/node-newrelic/commit/14717345d87ec46a4eba18c513e10e3caed40f7c))
18
+
19
+ #### Tests
20
+
21
+ * Added `samples` to prisma and next to cut down on versions under test on packages we recommend using hybrid ageninstrumentation ([#4112](https://github.com/newrelic/node-newrelic/pull/4112)) ([7d8bd7c](https://github.com/newrelic/node-newrelic/commit/7d8bd7cd2e3076d17ad25b75628956d1158fc23a))
22
+ * Resolved `grpc` `proto-loader` from the running suite's `node_modules` ([#4110](https://github.com/newrelic/node-newrelic/pull/4110)) ([5b5a9f8](https://github.com/newrelic/node-newrelic/commit/5b5a9f8d8e0f17557b9f202b0098e2ec84c9e028))
23
+
1
24
  ### v14.2.0 (2026-07-07)
2
25
 
3
26
  #### Features
@@ -12,11 +12,18 @@ const NrTransport = require('./nr-winston-transport.js')
12
12
  * during initial construction and on any subsequent reconfiguration.
13
13
  *
14
14
  * Handles `NrTransport` injection (after `configure` runs, via `end`).
15
+ *
16
+ * @property {boolean} handlingExceptions Indicates if this instrumentation has
17
+ * already registered a global exception handler or not. We only need a single
18
+ * exception handler per process.
15
19
  */
16
20
  module.exports = class WinstonConfigure extends ApplicationLogsSubscriber {
17
21
  constructor({ agent, logger }) {
18
22
  super({ agent, logger, channelName: 'nr_configure', packageName: 'winston' })
19
23
  this.events = ['end']
24
+ // we only want to assign `handleExceptions` to the first NrTransport
25
+ // customers could be constructing multiple logger instances
26
+ this.handlingExceptions = false
20
27
  }
21
28
 
22
29
  handler(data, ctx) {
@@ -39,11 +46,12 @@ module.exports = class WinstonConfigure extends ApplicationLogsSubscriber {
39
46
  const hasNrTransport = logger.transports?.some((t) => t.name === 'newrelic')
40
47
  if (!hasNrTransport) {
41
48
  const nrTransport = new NrTransport({ agent: this.agent })
42
- // Only handle exceptions if the logger has user-configured transports.
43
- // This prevents the default logger (created during require('winston')
44
- // module init with no transports) from double-handling exceptions.
45
- if (logger.transports.length === 0) {
46
- nrTransport.handleExceptions = false
49
+ // assigning `transport.handleExceptions` adds a global `process.on('uncaughtException')`
50
+ // handler. Doing it for more than one NrTransport instance will cause duplicate log lines
51
+ if (this.handlingExceptions === false && logger.transports.length > 0) {
52
+ // See: https://github.com/winstonjs/winston#handling-uncaught-exceptions-with-winston
53
+ nrTransport.handleExceptions = true
54
+ this.handlingExceptions = true
47
55
  }
48
56
  logger.add(nrTransport)
49
57
  }
@@ -14,12 +14,15 @@ const { truncate } = require('../../util/application-logging')
14
14
  *
15
15
  * Note*: This copies the log line so no other transports will get the
16
16
  * mutated data.
17
+ *
18
+ * @property {string} name name of the transport
19
+ * @property {Agent} agent the instance of agent
20
+ * @property {object} config the agent configuration
21
+ * @property {boolean} handleExceptions set in `lib/subscribers/winston/configure.js` for the first NrTransport instance
22
+ * to ensure that only one is handling uncaught exceptions in winston transports
17
23
  */
18
24
  class NrTransport extends TransportStream {
19
25
  constructor(opts = {}) {
20
- // set this option to have winston handle uncaught exceptions
21
- // See: https://github.com/winstonjs/winston#handling-uncaught-exceptions-with-winston
22
- opts.handleExceptions = true
23
26
  super(opts)
24
27
  this.name = 'newrelic'
25
28
  this.agent = opts.agent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "14.2.0",
3
+ "version": "14.2.1",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [
@@ -170,7 +170,7 @@
170
170
  "lint:fix": "eslint --fix .",
171
171
  "public-docs": "jsdoc -c ./jsdoc-conf.jsonc",
172
172
  "publish-docs": "./bin/publish-docs.sh",
173
- "services": "DOCKER_PLATFORM=linux/$(uname -m) docker compose up -d --wait",
173
+ "services": "./bin/start-services.sh",
174
174
  "services:start": "npm run services",
175
175
  "services:stop": "docker compose down",
176
176
  "smoke": "time borp --timeout 180000 --reporter ./test/lib/test-reporter.mjs 'test/smoke/**/*.test.js'",