Title: Request-specific context does not work with express · Issue #1939 · getsentry/sentry-javascript · GitHub
Open Graph Title: Request-specific context does not work with express · Issue #1939 · getsentry/sentry-javascript
X Title: Request-specific context does not work with express · Issue #1939 · getsentry/sentry-javascript
Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javascript/releases Package + Version @sentry...
Open Graph Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas...
X Description: Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/1939
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Request-specific context does not work with express","articleBody":"\u003c!-- Requirements: please go through this checklist before opening a new issue -->\r\n\r\n- [X] Review the documentation: https://docs.sentry.io/\r\n- [X] Search for existing issues: https://github.com/getsentry/sentry-javascript/issues\r\n- [X] Use the latest release: https://github.com/getsentry/sentry-javascript/releases\r\n\r\n## Package + Version\r\n\r\n- [ ] `@sentry/browser`\r\n- [X] `@sentry/node`\r\n- [ ] `raven-js`\r\n- [ ] `raven-node` _(raven for node)_\r\n- [ ] other:\r\n\r\n### Version:\r\n\r\n```\r\n4.6.4\r\n```\r\n\r\n## Description\r\n\r\nI'm having a lot of issues setting request-specific context when using Sentry with Express. As a reference, I took a look at the official Express integration docs, as well as the following issue and PR:\r\n\r\n- Docs: https://docs.sentry.io/platforms/node/express/\r\n- Issue: https://github.com/getsentry/sentry-javascript/issues/1632\r\n- Docs PR: https://github.com/getsentry/sentry-docs/pull/447/files (As an aside, I don't see these latest doc changes published anywhere though they were merged in)\r\n\r\n```js\r\nconst express = require('express')\r\nconst Sentry = require('@sentry/node')\r\nconst constants = require('./config/constants')\r\n\r\nconst api = express()\r\n\r\nSentry.init({\r\n dsn: constants.SENTRY_DSN_KEY,\r\n environment: constants.ENV_CURRENT\r\n})\r\n\r\napi.use(Sentry.Handlers.requestHandler())\r\napi.use((req, res, next) => {\r\n console.log('Point A', Sentry.getHubFromCarrier(req))\r\n Sentry.getHubFromCarrier(req).configureScope(scope => {\r\n console.log('Point B')\r\n scope.setTag('test', 'Tag')\r\n scope.setExtra('test', req.path)\r\n })\r\n\r\n throw new Error('Request-specific context does not work')\r\n})\r\n\r\napi.use(Sentry.Handlers.errorHandler())\r\napi.listen(constants.API_PORT)\r\n```\r\n\r\nConsole Output:\r\n\r\n```\r\nPoint A \r\nHub {\r\n version: 3,\r\n stack: [ { client: undefined, scope: [Object] } ] }\r\n\r\nError: Request-specific context does not work\r\n at api.use (api/index.js:21:10)\r\n at Layer.handle [as handle_request] (api/node_modules/express/lib/router/layer.js:95:5)\r\n at trim_prefix (api/node_modules/express/lib/router/index.js:317:13)\r\n at api/node_modules/express/lib/router/index.js:284:7\r\n at Function.process_params (api/node_modules/express/lib/router/index.js:335:12)\r\n at next (api/node_modules/express/lib/router/index.js:275:10)\r\n at Domain.\u003canonymous> (api/node_modules/@sentry/node/dist/handlers.js:161:13)\r\n at Domain.run (domain.js:242:14)\r\n at sentryRequestMiddleware (api/node_modules/@sentry/node/dist/handlers.js:155:15)\r\n at Layer.handle [as handle_request] (api/node_modules/express/lib/router/layer.js:95:5)\r\n```\r\n\r\nNotice from the console output above: \r\n- that `Point B` is never output in the console\r\n- `client` in the `stack` of the `Hub` instance is `undefined` - not sure if this is related\r\n\r\nUsing node `8.14.0` and express `4.16.4`.\r\n","author":{"url":"https://github.com/asabhaney","@type":"Person","name":"asabhaney"},"datePublished":"2019-03-05T22:21:14Z","url":"https://github.com/getsentry/sentry-javascript/issues/1939"}
| 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:adf7e868-41f4-e667-8466-efaa2d791873 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9EA4:2BB639:FA8991:15FACDF:6B0449DD |
| html-safe-nonce | e8c42a2d2e94892498a0b9c82dd35dda3fbcebead19cd7efa0a456569e0d193c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RUE0OjJCQjYzOTpGQTg5OTE6MTVGQUNERjo2QjA0NDlERCIsInZpc2l0b3JfaWQiOiIyNDI2MDA4ODY4NzM3MDEwMTQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 50b82b9ac780cb95d17de32e2f0a50d01b373c0c535d6c17cc8d6b4b28b3c3cf |
| hovercard-subject-tag | issue:417529067 |
| 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/1939/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0875657e3237a6a0520a39fb4a61c329955b892476a3858bb1630d8c012cf21f/getsentry/sentry-javascript/issues/1939 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0875657e3237a6a0520a39fb4a61c329955b892476a3858bb1630d8c012cf21f/getsentry/sentry-javascript/issues/1939 |
| og:image:alt | Review the documentation: https://docs.sentry.io/ Search for existing issues: https://github.com/getsentry/sentry-javascript/issues Use the latest release: https://github.com/getsentry/sentry-javas... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | asabhaney |
| hostname | github.com |
| expected-hostname | github.com |
| None | d4495c3631faba668036f176d1f5946901c5172efd73a6edb984029e7d4f8e46 |
| 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 | 9ac4337fb7c6a5846cdfdb1a04f154d3c33ebc77 |
| 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