Skip to content

Commit 024282b

Browse files
authored
Fix router not working with deeply nested middleware (#5890)
Fixes: #5881
1 parent 9a8a6ec commit 024282b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/datadog-instrumentations/src/router.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function createWrapRouterMethod (name) {
106106
}
107107

108108
function extractMatchers (fn) {
109-
const arg = Array.isArray(fn) ? fn : [fn]
109+
const arg = Array.isArray(fn) ? fn.flat(Infinity) : [fn]
110110

111111
if (typeof arg[0] === 'function') {
112112
return []

packages/datadog-plugin-router/test/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ describe('Plugin', () => {
111111
router.use((req, res, next) => {
112112
return next('route')
113113
})
114-
router.get('/foo', (req, res) => {
114+
router.get('/foo', [[[(_req, _res, next) => { next() }]]], (req, res) => {
115115
res.end()
116116
})
117117

0 commit comments

Comments
 (0)