Title: Sentry throws error when passing routes as Express middleware ( `use` ) · Issue #9360 · getsentry/sentry-javascript · GitHub
Open Graph Title: Sentry throws error when passing routes as Express middleware ( `use` ) · Issue #9360 · getsentry/sentry-javascript
X Title: Sentry throws error when passing routes as Express middleware ( `use` ) · Issue #9360 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/9360
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Sentry throws error when passing routes as Express middleware ( `use` )","articleBody":"### Is there an existing issue for this?\r\n\r\n- [X] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\r\n- [X] I have reviewed the documentation https://docs.sentry.io/\r\n- [X] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\r\n\r\n### How do you use Sentry?\r\n\r\nSentry Saas (sentry.io)\r\n\r\n### Which SDK are you using?\r\n\r\n@sentry/node\r\n\r\n### SDK Version\r\n\r\n7.74.1\r\n\r\n### Framework Version\r\n\r\nNode v18.16.1, Express v4.18.2\r\n\r\n### Link to Sentry event\r\n\r\nhttps://capdesk-org.sentry.io/issues/4568059536\r\n\r\n### SDK Setup\r\n\r\n```\r\n Sentry.init({\r\n dsn: SENTRY_DSN,\r\n integrations: [\r\n new Sentry.Integrations.Http({ tracing: true }),\r\n new Sentry.Integrations.Express({\r\n app,\r\n }),\r\n ],\r\n environment: ENV,\r\n ignoreErrors: [],\r\n })\r\n```\r\n\r\n### Steps to Reproduce\r\n\r\n1. When you provides routes to `app.use`, like so:\r\n```\r\napp.use(routes, frontendHandler)\r\n```\r\nWith the `frontendHandler` basically serving static assets:\r\n```\r\nexpress.static(path.join(__dirname, '../../build'))\r\n```\r\n2. And request any frontend route\r\n\r\n### Expected Result\r\n\r\nRoutes are served normally.\r\n\r\n### Actual Result\r\n\r\nThe following error gets thrown, crashing the express server:\r\n```\r\nTypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))\r\n at /Users/username/Code/reponame/node_modules/@sentry-internal/src/node/integrations/express.ts:439:1\r\n at Array.forEach (\u003canonymous>)\r\n at extractOriginalRoute (/Users/username/Code/reponame/node_modules/@sentry-internal/src/node/integrations/express.ts:439:1)\r\n at getLayerRoutePathInfo (/Users/username/Code/reponame/node_modules/@sentry-internal/tracing/cjs/node/integrations/express.js:409:13)\r\n at Function.process_params (/Users/username/Code/reponame/node_modules/@sentry-internal/src/node/integrations/express.ts:316:1)\r\n at next (/Users/username/Code/reponame/node_modules/express/lib/router/index.js:280:10)\r\n at Function.handle (/Users/username/Code/reponame/node_modules/express/lib/router/index.js:175:3)\r\n at router (/Users/username/Code/reponame/node_modules/express/lib/router/index.js:47:12)\r\n at /Users/username/Code/reponame/node_modules/@sentry-internal/src/node/integrations/express.ts:183:1\r\n at Layer.handle [as handle_request] (/Users/username/Code/reponame/node_modules/express/lib/router/layer.js:95:5)\r\n```\r\n\r\nSeems related to [this commit](https://github.com/getsentry/sentry-javascript/commit/755ba739de8aeb2de574df73f7d3941001b44983). Using `app.all` instead works correctly, like so:\r\n```\r\napp.all(routes, frontendHandler)\r\n```\r\nProblem is that using `all` and `use` aren't exactly equivalent.","author":{"url":"https://github.com/etarhan","@type":"Person","name":"etarhan"},"datePublished":"2023-10-25T08:45:11Z","url":"https://github.com/getsentry/sentry-javascript/issues/9360"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:118545fd-d325-cd25-b28b-bef0a9199eaa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A066:20A8C6:2F9917:41585E:6B046AF3 |
| html-safe-nonce | 20857532c62da18312cd3b07fd9ce6bcc2bbc565ab61d1111708515838703541 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDY2OjIwQThDNjoyRjk5MTc6NDE1ODVFOjZCMDQ2QUYzIiwidmlzaXRvcl9pZCI6IjExMzUzMjU3ODk4OTQ3NjUyOTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b05ecd2d93ef86a283e140550acb0f2b4ef6908bf9c4933dfaac257f2eb142ab |
| hovercard-subject-tag | issue:1960871386 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/9360/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3c47dae65c78462a154aa0655bb9e21ac9b5b21a34645180601b9c80c4ced768/getsentry/sentry-javascript/issues/9360 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3c47dae65c78462a154aa0655bb9e21ac9b5b21a34645180601b9c80c4ced768/getsentry/sentry-javascript/issues/9360 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | etarhan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width