Skip to content

Commit b96f16e

Browse files
author
Peter Bengtsson
authored
too often we don't know the path of 503'ing requests (#23744)
* Too often we don't know the path of 503'ing requests * actually, use both
1 parent a736b53 commit b96f16e

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

middleware/timeout.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ export default timeout.handler({
1616
disable: [],
1717

1818
onTimeout: function (req, res, next) {
19-
const incrementTags = []
20-
// Be careful with depending on attributes set on the `req` because
21-
// under certain conditions the contextualizers might not yet have
22-
// had a chance to run.
23-
if (req.pagePath) {
24-
incrementTags.push(`path:${req.pagePath}`)
25-
}
19+
// The `req.pagePath` can come later so it's not guaranteed to always
20+
// be present. It's added by the `handle-next-data-path.js` middleware
21+
// we translates those "cryptic" `/_next/data/...` URLs from
22+
// client-side routing.
23+
const incrementTags = [`path:${req.pagePath || req.path}`]
2624
if (req.context?.currentCategory) {
2725
incrementTags.push(`product:${req.context.currentCategory}`)
2826
}

0 commit comments

Comments
 (0)