Title: Custom path options for SENTRY_SERVER_INIT_PATH to use in monorepo environments. · Issue #3723 · getsentry/sentry-javascript · GitHub
Open Graph Title: Custom path options for SENTRY_SERVER_INIT_PATH to use in monorepo environments. · Issue #3723 · getsentry/sentry-javascript
X Title: Custom path options for SENTRY_SERVER_INIT_PATH to use in monorepo environments. · Issue #3723 · 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 Provide a link to the aff...
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/3723
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Custom path options for SENTRY_SERVER_INIT_PATH to use in monorepo environments.","articleBody":"- [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- [ ] Provide a link to the affected event from your Sentry account\r\n\r\n## Package + Version\r\n\r\n- [x] `@sentry/nextjs`\r\n\r\n### Version:\r\n\r\n```\r\n6.7.1\r\n```\r\n\r\n## Description\r\n\r\nWhen using `@sentry/nextjs` in a [@nrwl/nx](https://nx.dev) monorepo workspace environment, the output path is applied to `.env.local` file relative to the \"application\" path, which resolves to this in development environment (as `dist` folder is in workspace root but app source is in `apps/\u003capp-name>` directory):\r\n\r\n```\r\nSENTRY_SERVER_INIT_PATH=..\\..\\dist\\apps\\\u003capp-name>\\.next\\server\\sentry\\initServerSDK.js\r\n```\r\n\r\nWhich is correct as it gets the output from the webpack config. But in the nx workspace environment, the serve and build commands must be executed from the workspace root and not the next app root, so this relative path becomes wrong for both the development server and the production build pipeline (as in most cases only the built artifacts are cloned over).\r\n\r\nSo this error is thrown:\r\n```\r\n[Sentry] Could not initialize SDK. Received error:\r\nError: Cannot find module 'C:\\Users\\\u003cusername>\\Desktop\\dist\\apps\\\u003capp-name>\\.next\\server\\sentry\\initServerSDK.js'\r\nRequire stack:\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@sentry\\nextjs\\dist\\utils\\instrumentServer.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@sentry\\nextjs\\dist\\index.server.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\apps\\promocodes.com\\next.config.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\next\\dist\\next-server\\server\\config.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@nrwl\\next\\src\\utils\\config.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@nrwl\\next\\src\\executors\\server\\server.impl.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@nrwl\\tao\\src\\shared\\workspace.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@nrwl\\tao\\src\\commands\\run.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@nrwl\\tao\\index.js\r\n- C:\\Users\\\u003cusername>\\Desktop\\Dev\\\u003cworkspace-name>\\node_modules\\@nrwl\\cli\\lib\\run-cli.js\r\n```\r\n\r\nNote: I have also tried providing this environment variable in the next.config.js, it still defaults to loading the .env.local file, which gets overwritten on every serve or build command execution.\r\n\r\n## Proposed Solution\r\n\r\nI confirmed if I run a production server after removing the double back directories from `.env.local` file, the SDK boots up correctly and is initialized. So I could probably get around this in the CI pipeline by monkey patching the file, or just adding a DefinePlugin for that env variable to the nextjs webpack config, but that would not be a very good solution. As for my proposed solution, there should be an option to define `SENTRY_SERVER_INIT_PATH` with it defaulting to self-overwriting `.env.local` as the `@sentry/nextjs` config does at the moment.\r\n","author":{"url":"https://github.com/Saegusae","@type":"Person","name":"Saegusae"},"datePublished":"2021-06-21T22:35:09Z","url":"https://github.com/getsentry/sentry-javascript/issues/3723"}
| 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:7d08f269-09a9-ce66-4c81-3129b29326b8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DD6:176400:105A44D:16DDB58:6B0449D1 |
| html-safe-nonce | ac719b1f9966da6f4a4fb92d6c1568895ebb78c0ce0c94674e4deea65fec1a78 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REQ2OjE3NjQwMDoxMDVBNDREOjE2RERCNTg6NkIwNDQ5RDEiLCJ2aXNpdG9yX2lkIjoiNTE0NDAyNzM3ODEwODA5MDgzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7b0a71deff2343720e76a962061022ec26de2aa221d4b37559f2ca2e802e6c6c |
| hovercard-subject-tag | issue:926661560 |
| 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/3723/issue_layout |
| twitter:image | https://opengraph.githubassets.com/39256cd0bc7fe5afa24155d5fe550cf164bc160deb970f4acb2d06ddca4602ea/getsentry/sentry-javascript/issues/3723 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/39256cd0bc7fe5afa24155d5fe550cf164bc160deb970f4acb2d06ddca4602ea/getsentry/sentry-javascript/issues/3723 |
| 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 | Saegusae |
| 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