Skip to content

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 2 commits into from
Jan 29, 2025

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Jan 27, 2025

perfect PR id 😈

This PR

  • improves the check for if the plugin is called in dev/watch mode or for a production build. In case of the former, we return a no-op plugin. This was already the expected behaviour previously but due to the unplugin meta context only holding the watchmode flag in theory but not in practise, we'd always return the actual plugins.
  • avoids adding the release management (+legacy upload) and debug id upload plugins because we don't want to make API calls when in dev mode. In reality this rarely happened due to the writeBundle hook usually not being called in dev. But, most importantly also
  • avoids spamming the dev server logs with warnings about the missing auth token. It's totally in fair to not set up an auth token in dev mode and we'd previously add two unnecessary warnings for it (cc @cleptric)

closes #344
probably also closes #520 (I'll leave a reply to get confirmation)

@Lms24 Lms24 self-assigned this Jan 27, 2025
@Lms24 Lms24 requested a review from lforst January 27, 2025 12:21
@@ -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(
Copy link
Member Author

Choose a reason for hiding this comment

The 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)

@Lms24
Copy link
Member Author

Lms24 commented Jan 27, 2025

Some more context on the watchmode flag:

Unplugin union-types the UnpluginMetaContext with Rollup's PluginMetaContext. The watchmode flag comes from Rollup's type. However, when the plugin factory function is called, the meta object is only populated with a small subset of properties--mostly framework: https://github.com/unjs/unplugin/blob/a5fe8fe418064b2ca9cdecb2c8ddd1a6c2fe36fe/src/vite/index.ts#L9-L12

@@ -106,7 +111,7 @@ export function sentryUnpluginFactory({

const options = normalizeUserOptions(userOptions);

if (unpluginMetaContext.watchMode || options.disable) {
Copy link

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?

Copy link
Member Author

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?

@Lms24 Lms24 merged commit d39f50e into main Jan 29, 2025
18 checks passed
@Lms24 Lms24 deleted the lms/check-for-node-env branch January 29, 2025 14:22
@Lms24 Lms24 changed the title fix(core): Check for dev mode via process.env.NODE_ENV fix(core): Disable release creation and source maps upload in dev mode Jan 29, 2025
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Jan 31, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.1.0 | 3.1.1 |


## [v3.1.1](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#311)

-   fix(core): Disable release creation and source maps upload in dev mode ([#666](getsentry/sentry-javascript-bundler-plugins#666))

    This fix disables any external calls to the Sentry API for managing releases or uploading source maps, when detecting that the plugin is running in dev-mode. While this rarely actually happened,
    it also polluted the dev server output with unnecessary logs about missing auth tokens, which shouldn't
    be required in dev mode.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 1, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.1.0 | 3.1.1 |


## [v3.1.1](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#311)

-   fix(core): Disable release creation and source maps upload in dev mode ([#666](getsentry/sentry-javascript-bundler-plugins#666))

    This fix disables any external calls to the Sentry API for managing releases or uploading source maps, when detecting that the plugin is running in dev-mode. While this rarely actually happened,
    it also polluted the dev server output with unnecessary logs about missing auth tokens, which shouldn't
    be required in dev mode.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 5, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.1.0 | 3.1.2 |


## [v3.1.2](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#312)

-   deps: Bump `@sentry/cli` to `2.41.1` ([#671](getsentry/sentry-javascript-bundler-plugins#671))


## [v3.1.1](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#311)

-   fix(core): Disable release creation and source maps upload in dev mode ([#666](getsentry/sentry-javascript-bundler-plugins#666))

    This fix disables any external calls to the Sentry API for managing releases or uploading source maps, when detecting that the plugin is running in dev-mode. While this rarely actually happened,
    it also polluted the dev server output with unnecessary logs about missing auth tokens, which shouldn't
    be required in dev mode.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 5, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.1.0 | 3.1.2 |


## [v3.1.2](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#312)

-   deps: Bump `@sentry/cli` to `2.41.1` ([#671](getsentry/sentry-javascript-bundler-plugins#671))


## [v3.1.1](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#311)

-   fix(core): Disable release creation and source maps upload in dev mode ([#666](getsentry/sentry-javascript-bundler-plugins#666))

    This fix disables any external calls to the Sentry API for managing releases or uploading source maps, when detecting that the plugin is running in dev-mode. While this rarely actually happened,
    it also polluted the dev server output with unnecessary logs about missing auth tokens, which shouldn't
    be required in dev mode.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 7, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.1.0 | 3.1.2 |


## [v3.1.2](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#312)

-   deps: Bump `@sentry/cli` to `2.41.1` ([#671](getsentry/sentry-javascript-bundler-plugins#671))


## [v3.1.1](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#311)

-   fix(core): Disable release creation and source maps upload in dev mode ([#666](getsentry/sentry-javascript-bundler-plugins#666))

    This fix disables any external calls to the Sentry API for managing releases or uploading source maps, when detecting that the plugin is running in dev-mode. While this rarely actually happened,
    it also polluted the dev server output with unnecessary logs about missing auth tokens, which shouldn't
    be required in dev mode.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Feb 8, 2025
| datasource | package             | from  | to    |
| ---------- | ------------------- | ----- | ----- |
| npm        | @sentry/vite-plugin | 3.1.0 | 3.1.2 |


## [v3.1.2](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#312)

-   deps: Bump `@sentry/cli` to `2.41.1` ([#671](getsentry/sentry-javascript-bundler-plugins#671))


## [v3.1.1](https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/HEAD/CHANGELOG.md#311)

-   fix(core): Disable release creation and source maps upload in dev mode ([#666](getsentry/sentry-javascript-bundler-plugins#666))

    This fix disables any external calls to the Sentry API for managing releases or uploading source maps, when detecting that the plugin is running in dev-mode. While this rarely actually happened,
    it also polluted the dev server output with unnecessary logs about missing auth tokens, which shouldn't
    be required in dev mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webpack plugin uploads source maps on development mode [Vite] No auth token provided in dev/watch mode warning
2 participants