-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Custom path options for SENTRY_SERVER_INIT_PATH to use in monorepo environments. #3723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I suspect this error gets thrown when Sentry's self executing function (that runs when withSentryConfig is imported in the next.config.js file) can not read the environment variable SENTRY_SERVER_INIT_PATH. So it's most likely related to the issue. |
I'm running into the same issue with Nx. If I set the ENV var, it works... but it's overwritten and fails the second time around. |
@Saegusae Not ideal, but I did this at the top of my
|
@tmilewski yeah, i did something similar by injecting the env var before the run script. We should at least be able to stop sentry for injecting code and throwing errors on development environment (since it's not required on the local machine dev server). |
@tmilewski @Saegusae @shertu This should be fixed in 6.9.0, as we switched our approach and no longer are using the env file or env variable. |
Package + Version
@sentry/nextjs
Version:
Description
When using
@sentry/nextjs
in a @nrwl/nx monorepo workspace environment, the output path is applied to.env.local
file relative to the "application" path, which resolves to this in development environment (asdist
folder is in workspace root but app source is inapps/<app-name>
directory):Which 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).
So this error is thrown:
Note: 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.
Proposed Solution
I 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 defineSENTRY_SERVER_INIT_PATH
with it defaulting to self-overwriting.env.local
as the@sentry/nextjs
config does at the moment.The text was updated successfully, but these errors were encountered: