-
Notifications
You must be signed in to change notification settings - Fork 42
fix(core): Disable release creation and source maps upload in dev mode #666
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,11 @@ export function sentryUnpluginFactory({ | |
debug: userOptions.debug ?? false, | ||
}); | ||
|
||
// Not a bulletproof check but should be good enough to at least sometimes determine | ||
// if the plugin is called in dev/watch mode or for a prod build. The important part | ||
// here is to avoid a false positive. False negatives are okay. | ||
const isDevMode = process.env["NODE_ENV"] === "development"; | ||
|
||
try { | ||
const dotenvFile = fs.readFileSync( | ||
path.join(process.cwd(), ".env.sentry-build-plugin"), | ||
|
@@ -106,7 +111,7 @@ export function sentryUnpluginFactory({ | |
|
||
const options = normalizeUserOptions(userOptions); | ||
|
||
if (unpluginMetaContext.watchMode || options.disable) { | ||
if (options.disable) { | ||
return [ | ||
{ | ||
name: "sentry-noop-plugin", | ||
|
@@ -274,7 +279,7 @@ export function sentryUnpluginFactory({ | |
"Release injection disabled via `release.inject` option. Will not inject release." | ||
); | ||
} else if (!options.release.name) { | ||
logger.warn( | ||
logger.debug( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also took the liberty to relax the log level here. Releases aren't required anymore for debugId-based upload and I've seen build logs this and the log below were added (in fact multiple times due to multi-build-setups of meta frameworks like SvelteKit and Nuxt) |
||
"No release name provided. Will not inject release. Please set the `release.name` option to identify your release." | ||
); | ||
} else { | ||
|
@@ -316,9 +321,11 @@ export function sentryUnpluginFactory({ | |
} | ||
|
||
if (!options.release.name) { | ||
logger.warn( | ||
logger.debug( | ||
"No release name provided. Will not create release. Please set the `release.name` option to identify your release." | ||
); | ||
} else if (isDevMode) { | ||
logger.debug("Running in development mode. Will not create release."); | ||
} else if (!options.authToken) { | ||
logger.warn( | ||
"No auth token provided. Will not create release. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" | ||
|
@@ -367,6 +374,8 @@ export function sentryUnpluginFactory({ | |
logger.debug( | ||
"Source map upload was disabled. Will not upload sourcemaps using debug ID process." | ||
); | ||
} else if (isDevMode) { | ||
logger.debug("Running in development mode. Will not upload sourcemaps."); | ||
} else if (!options.authToken) { | ||
logger.warn( | ||
"No auth token provided. Will not upload source maps. Please set the `authToken` option. You can find information on how to generate a Sentry auth token here: https://docs.sentry.io/api/auth/" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is technically not the goal of this PR but thinking about this logic more holistically we probably don't want to disable the entire plugin for dev mode because we have other things that may be valuable in dev mode, like react component annotations or tree shaking utilities (I guess for debugging purposes).
Should we limit this check to just anything that has a side-effect/is invoking Sentry CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, we can adjust this further. I think what we want to disable is release management and sourcemaps upload, right? release and debugId injection should be fine in dev as well, right?