Repository navigation
feat: expose the matched route pattern on the tracing context - #207
Conversation
|
You can use my PR, no problem. You have commit access, so you can use the GitHub CLI to push to my branch |
|
We can keep them separate to avoid muddying your PR, will rebase/undraft this PR once yours merges! If you think it belongs there, then happy to push it. Up to you. |
|
Hmm, I’m not sure. If you want, take a look at my PR. How about we give Ulises and the other reviewers a week to review it, then merge it and take a look at yours? |
|
please rebase |
4896d50 to
27974cb
Compare
Layer instances are shared across requests, so reading a matched pattern after asynchronous parameter processing can pick up another request's pattern or lose it after a non-match. Nested routers can also leave their pattern on handlers that resume in the outer route. Let Layer.match optionally return the registered pattern while preserving its existing boolean behavior. Capture the pattern on req before running parameter callbacks, and restore the parent value alongside the other router state when a nested router returns. Tracing then reads from one request-local source instead of mutable state on a shared Layer. Pattern capture and restoration use synchronous property access and the existing restoration callback. Route.dispatch and handler signatures stay unchanged, with no additional asynchronous context mechanism or per-layer callback allocation. Cover concurrent requests, nested router returns and errors, parameter callbacks that invoke routers, and string, array, RegExp and empty patterns. Validation: 768 tests passing, npm run lint, and npm run test-types.
882706f to
297875e
Compare
|
Okay, I made the change to keep the state isolated per request. Previously, the pattern was stored on Now:
The state is now isolated per request. Capturing and restoring it are synchronous |
Tracing subscribers couldn't tell which route pattern matched a request, fixed by adding a
routefield to theexpress.router.requestcontext, built onrawPathfrom #174.I added tests for middleware, route handlers, route error handlers, mounted routers, and array paths where only one entry matches.