newrelic 13.6.0 → 13.6.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,13 @@
1
+ ### v13.6.1 (2025-10-28)
2
+
3
+ #### Bug fixes
4
+
5
+ * Updated middleware wrapper to not wrap handler if it is not a function ([#3469](https://github.com/newrelic/node-newrelic/pull/3469)) ([c702689](https://github.com/newrelic/node-newrelic/commit/c702689a6e73756f6b3ad39706a33874fbd6da73))
6
+
7
+ #### Documentation
8
+
9
+ * Updated compatibility report ([#3466](https://github.com/newrelic/node-newrelic/pull/3466)) ([5853657](https://github.com/newrelic/node-newrelic/commit/5853657a63dc75481fc6598c10afd208391f525b))
10
+
1
11
  ### v13.6.0 (2025-10-27)
2
12
 
3
13
  #### Features
@@ -8000,3 +8010,4 @@ Special thanks to Ryan Copley (@RyanCopley) for the contribution.
8000
8010
 
8001
8011
 
8002
8012
 
8013
+
@@ -23,12 +23,14 @@ class ExpressUseSubscriber extends MiddlewareSubscriber {
23
23
  fnIndex = 0
24
24
  }
25
25
  let segmentName = null
26
+ // sometimes route is undefined, default to `/` for segmentName only
27
+ const routeName = route || '/'
26
28
  // Pre v5 these were marked as `lazyrouter`
27
29
  // check for both
28
30
  if (fn.lazyrouter || fn.name === 'mounted_app') {
29
- segmentName = `${this.wrapper.system}/Mounted App: ${route}`
31
+ segmentName = `${this.wrapper.system}/Mounted App: ${routeName}`
30
32
  } else if (fn.stack) {
31
- segmentName = `${this.wrapper.system}/Router: ${route}`
33
+ segmentName = `${this.wrapper.system}/Router: ${routeName}`
32
34
  method = 'handle'
33
35
  }
34
36
 
@@ -59,8 +59,17 @@ class MiddlewareWrapper {
59
59
  */
60
60
  wrap({ handler, prefix, route, segmentName, nextIdx = -1 }) {
61
61
  const self = this
62
+ if (typeof handler !== 'function') {
63
+ this.logger.trace('Handler: %s is not a function, not wrapping.', handler)
64
+ return handler
65
+ }
66
+
62
67
  function wrappedHandler (...args) {
63
68
  const ctx = self.agent.tracer.getContext()
69
+ if (ctx?.transaction?.isActive() !== true) {
70
+ self.logger.trace('No active transaction, calling original function')
71
+ return handler.apply(this, args)
72
+ }
64
73
  const transaction = ctx?.transaction
65
74
  transaction.nameState.setPrefix(self.system)
66
75
  const { txInfo, errorWare, request } = self.extractTxInfo(args, route)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "13.6.0",
3
+ "version": "13.6.1",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "license": "Apache-2.0",
6
6
  "contributors": [