Skip to content

fix(server-utils): Read Express mount paths from the router 2.3 layer - #26729

Merged
JPeer264 merged 2 commits into
developfrom
jp/express-router-raw-path
Nov 23, 2026
Merged

JPeer264 merged 2 commits into
developfrom
jp/express-router-raw-path

Conversation

@JPeer264

@JPeer264 JPeer264 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

follow up to #26560

This fixes the name of a request to a route of a mounted router, for example GET /api/posts/:postId for app.use('/api', router), when the router layer gets no registration event.

Why

Without a registration event, the SDK builds the route from the matched layer. That is the case for each mount on Cloudflare, where the events arrive with the first request, and on all runtimes for parentRouter.use('/api', router, handler), where only the last layer gets the event. router 2.3.0 (released 2026-11-17), which every new Express 5 install gets, no longer stores the matched path on the layer. So /api/posts/7 was named GET /posts/:postId, and on Cloudflare a mount path with parameters gave only GET. The SDK now reads the registered rawPath of the layer, which also keeps the parameters.

Known issues

  • Express 4 has no rawPath, so on Cloudflare a mount path with parameters still gives only GET.

Sentry traces

Before, /api/posts/7 named GET /posts/:postId: https://sentry-sdks.sentry.io/explore/traces/trace/75115b7860c44fefa7805d93c308b776/?node=span-8893a74ff1675624&project=4510555608449024&source=traces&targetId=8893a74ff1675624&timestamp=1795205375
Before, /orgs/acme/members named GET: https://sentry-sdks.sentry.io/explore/traces/trace/d6bcbc56dff2405ab6b9fda4512eb9d6/?node=span-bd415b66001f06dd&project=4510555608449024&source=traces&targetId=bd415b66001f06dd&timestamp=1795205375
After, /api/posts/7 named GET /api/posts/:postId: https://sentry-sdks.sentry.io/explore/traces/trace/6554eec06f10401c8223c85df325ad9c/?node=span-9b4740b027fd4eef&project=4510555608449024&source=traces&targetId=9b4740b027fd4eef&timestamp=1795205390
After, /orgs/acme/members named GET /orgs/:orgId/members: https://sentry-sdks.sentry.io/explore/traces/trace/4c02b3d21e3345b99b1a214779410291/?node=span-8edec24e30745aa4&project=4510555608449024&source=traces&targetId=8edec24e30745aa4&timestamp=1795205390

On Cloudflare, the Express registration events arrive with the first
request, so the route of a mounted router is built from the matched
layer. `router` 2.3.0, which new Express 5 installs get, no longer
stores the matched `path` on the layer, so the mount path was lost:
`GET /api/posts/:postId` became `GET /posts/:postId`, and a mount path
with parameters gave only `GET`. The layer now gives its registered
`rawPath`, which also keeps the parameters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 2cca52d (PR test merge using develop at 5a39728)

Against: 5a39728 (develop) · base run #67386

✅ Baseline matches: this diff contains only this PR's changes.

Path Size % Change Change
@sentry/browser 30.23 kB - -
@sentry/browser - with treeshaking flags 28.43 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.33 kB - -
@sentry/browser (incl. Tracing) 52.81 kB - -
@sentry/browser (incl. Tracing Core) 40.33 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 52.81 kB - -
@sentry/browser (incl. Tracing, Profiling) 55.69 kB - -
@sentry/browser (incl. Tracing, Replay) 92.88 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 81.7 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 97.22 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 110.8 kB - -
@sentry/browser (incl. Feedback) 48.17 kB - -
@sentry/browser (incl. sendFeedback) 30.81 kB - -
@sentry/browser (incl. FeedbackAsync) 35.84 kB - -
@sentry/browser (incl. Metrics) 31.55 kB - -
@sentry/browser (incl. Logs) 31.83 kB - -
@sentry/browser (incl. Metrics & Logs) 32.49 kB - -
@sentry/react 32.24 kB - -
@sentry/react (incl. Tracing) 55.45 kB - -
@sentry/vue 38.45 kB - -
@sentry/vue (incl. Tracing) 55.75 kB - -
@sentry/svelte 30.24 kB - -
@sentry/remix (Remix 3 client bundle) 58.46 kB - -
CDN Bundle 32.16 kB - -
CDN Bundle (incl. Tracing) 53.19 kB - -
CDN Bundle (incl. Logs, Metrics) 34.95 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 55.76 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.02 kB - -
CDN Bundle (incl. Tracing, Replay) 91.1 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 93.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 96.51 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.07 kB - -
CDN Bundle - uncompressed 93.91 kB - -
CDN Bundle (incl. Tracing) - uncompressed 157.26 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.24 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 164.88 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 232.48 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 277.53 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 285.16 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 289.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 297.08 kB - -
@sentry/nextjs (client) 59.15 kB - -
@sentry/sveltekit (client) 54.06 kB - -
@sentry/core/server 45.28 kB - -
@sentry/core/browser 14.41 kB - -
@sentry/node 155.25 kB +0.01% +13 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.46 kB - -
@sentry/node - without tracing 88.93 kB +0.02% +14 B 🔺
@sentry/node - without channel injection 144.16 kB +0.01% +6 B 🔺
@sentry/aws-serverless 99.56 kB +0.01% +7 B 🔺
@sentry/cloudflare (withSentry) - minified 208.88 kB - -
@sentry/cloudflare (withSentry) 484.65 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 1.02 MB - -
@sentry/nextjs/cloudflare (withSentry) - minified 234.11 kB - -

View base workflow run

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 7 not successful, 54 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Failing after 45s Details
❌ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Failing after 2m Details
❌ CI: Optional E2E Tests / E2E node-openai-decisions Test (optional) Failing after 35s Details
❌ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Failing after 1m Details
❌ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Failing after 28s Details
❌ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Failing after 3m Details
❌ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Failing after 25s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E node-flue Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (deno) Test (optional) Successful in 56s Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E express-5 (deno) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries Test (optional) Successful in 46s Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E express-5 (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E astro-7 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E gen-ai-libraries (cloudflare) Test (optional) Successful in 45s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E express-5 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 35s Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (cloudflare, latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-eve Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (bun) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Successful in 4m Details
✅ CI: Optional E2E Tests / E2E cloudflare-mastra Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 34s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nestjs-12 (cloudflare) Test (optional) Successful in 31s Details
✅ CI: Optional E2E Tests / E2E node-mastra Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 37s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 27s Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 40s Details
✅ CI: Optional E2E Tests / E2E node-pi-durable Test (optional) Successful in 33s Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 30s Details
✅ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 44s Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 55s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-cloudflare Test (optional) Successful in 29s Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 39s Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details

@JPeer264 JPeer264 self-assigned this Nov 22, 2026
@JPeer264
JPeer264 marked this pull request as ready for review November 22, 2026 15:35
@JPeer264
JPeer264 merged commit 30efdc0 into develop Nov 23, 2026
366 of 373 checks passed
@JPeer264
JPeer264 deleted the jp/express-router-raw-path branch November 23, 2026 12:34
JPeer264 added a commit to getsentry/sentry-docs that referenced this pull request Nov 23, 2026
<!-- Keep the urgency section so automation can prioritize this PR. You
may delete other sections you don't need. -->

## DESCRIBE YOUR PR

_Tell us what you're changing and why. If your PR **resolves an issue**,
please link it so it closes automatically._

follow up to getsentry/sentry-javascript#24845

This adds Express to the framework selector of the Cloudflare quick
start. With Express selected, the page shows the `httpServerHandler`
Worker entry and the Express verify snippet, as the Bun and Deno quick
starts do. The Express guide now links Cloudflare Workers next to
Node.js, Bun and Deno.

### Why

Since `@sentry/cloudflare` 11.15.0, the Vite plugin names Express
requests after their route and captures route errors on Workers
(getsentry/sentry-javascript#26559, getsentry/sentry-javascript#26560).
With getsentry/sentry-javascript#26729, routes of mounted routers also
keep their mount path with `router` 2.3.0. The docs had no Express setup
for Cloudflare.

### Known issues

- On Cloudflare, a mount path with parameters (`app.use("/orgs/:orgId",
router)`) gives only `GET` with Express 4, and with Express 5 on
`router` older than 2.3.0. The Express block shows this as a warning.

## IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs
to go live.
Select exactly one option. For deadlines, replace `YYYY-MM-DD` with the
due date. You can update this information later by editing the PR
description.

- [ ] Urgent deadline (GA date, etc.): YYYY-MM-DD
- [ ] Other deadline: YYYY-MM-DD
- [x] No deadline: Not urgent, can wait up to 1 week+

## SLA

- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
supplied a deadline.

Thanks in advance for your help!

## PRE-MERGE CHECKLIST

_Make sure you've checked the following before merging your changes:_

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

## LEGAL BOILERPLATE

<!-- Sentry employees and contractors can delete or ignore this section.
-->

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.

## EXTRA RESOURCES

- [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants