Skip to content

feat(bundler-plugins)!: Migrate from @sentry/cli to the sentry CLI SDK - #23398

Merged
JPeer264 merged 11 commits into
developfrom
jp/cli-v3-migration
Aug 28, 2026
Merged

feat(bundler-plugins)!: Migrate from @sentry/cli to the sentry CLI SDK#23398
JPeer264 merged 11 commits into
developfrom
jp/cli-v3-migration

Conversation

@JPeer264

@JPeer264 JPeer264 commented Aug 13, 2026

Copy link
Copy Markdown
Member

closes #18518
closes JS-1312

This PR is removing @sentry/cli in favor of sentry.

Following was done:

  • Using a SentryCliAdapter to make the usage a little bit more comfortable (especially around uploading sourcemaps for more projects)
  • On top there is the need for the escape hatch .run() for the release.deploy command (this should be fixed with fix(sdk): pass each positional argument as its own argv token cli#1415) Shipped with 0033c76
  • I was in between mocking the CLI and not mocking the CLI, as it would increase the CI 4 times by just using the real CLI. So I kept a mock like we had before
  • Removed sentryCliBinaryExists, because there is no binary anymore
  • Also added a new test for nuxt-sourcemaps (as we only had React Router 8 and Next - thought Nuxt is next in line to get a test) They got added after this PR got opened - I added one additional test for nuxt

@JPeer264 JPeer264 self-assigned this Aug 13, 2026
@linear-code

linear-code Bot commented Aug 13, 2026

Copy link
Copy Markdown

JS-1312

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 28.56 kB - -
@sentry/browser - with treeshaking flags 26.92 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.82 kB - -
@sentry/browser (incl. Tracing) 48.63 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.64 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.55 kB - -
@sentry/browser (incl. Tracing, Replay) 88.09 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.52 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.79 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.73 kB - -
@sentry/browser (incl. Feedback) 46.05 kB - -
@sentry/browser (incl. sendFeedback) 33.62 kB - -
@sentry/browser (incl. FeedbackAsync) 38.73 kB - -
@sentry/browser (incl. Metrics) 29.51 kB - -
@sentry/browser (incl. Logs) 29.8 kB - -
@sentry/browser (incl. Metrics & Logs) 30.43 kB - -
@sentry/react 30.3 kB - -
@sentry/react (incl. Tracing) 50.83 kB - -
@sentry/vue 35.69 kB - -
@sentry/vue (incl. Tracing) 50.86 kB - -
@sentry/svelte 28.59 kB - -
CDN Bundle 30.35 kB - -
CDN Bundle (incl. Tracing) 49.23 kB - -
CDN Bundle (incl. Logs, Metrics) 32.58 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.12 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.17 kB - -
CDN Bundle (incl. Tracing, Replay) 86.72 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.62 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.5 kB - -
CDN Bundle - uncompressed 89.95 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.82 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.24 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.51 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.41 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.32 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.02 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.69 kB - -
@sentry/nextjs (client) 53.41 kB - -
@sentry/sveltekit (client) 49.07 kB - -
@sentry/core/server 65.15 kB - -
@sentry/core/browser 51.8 kB - -
@sentry/node 122.74 kB +0.02% +17 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.23 kB - -
@sentry/node - without tracing 87.74 kB +0.03% +25 B 🔺
@sentry/node - without channel injection 102.4 kB +0.02% +16 B 🔺
@sentry/aws-serverless 95.9 kB +0.03% +25 B 🔺
@sentry/cloudflare (withSentry) - minified 199.69 kB - -
@sentry/cloudflare (withSentry) 496.19 kB - -

View base workflow run

@JPeer264

Copy link
Copy Markdown
Member Author

This PR is currently blocked by getsentry/cli#1421

betegon pushed a commit to getsentry/cli that referenced this pull request Aug 14, 2026
I opened a PR that is using the new CLI instead of the old
`@sentry/cli@2`:
getsentry/sentry-javascript#23398

Some E2E tests failed with `TypeError: Bun.serve is not a function`,
because we actually check internally if `Bun` would be an option. With
that polyfill in this CLI this behavior is now forced, without Bun
actually being there. Idk why this actually exists, but exporting `Bun`
instead fixes it.

---

AI description:

The Node polyfills were installed with `globalThis.Bun = BunPolyfill`,
which broke consumers of the npm package in both directions.

Under Bun the global is readonly, so merely importing the package threw
"Attempted to assign to readonly property" and took the whole process
down. Under Node it left an object named `Bun` on the global, so
unrelated libraries that feature-detect `typeof Bun !== "undefined"`
took their Bun code path and called methods the polyfill does not
implement, failing with errors like "Bun.serve is not a function". Both
are reachable by anyone who merely depends on this package, since
importing it is enough.

The polyfills are already delivered through esbuild's `inject`, which
substitutes unbound identifiers with exported bindings, so exporting
`Bun` gives the bundle the same value lexically without touching the
global. The real Bun is preferred when present, so running under Bun
keeps the genuine implementation rather than shadowing it.

Verified by importing the built bundle in Node: `globalThis.Bun` stays
undefined, where it previously became an object whose `serve` and
`version` were missing.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cli-v3-migration branch 6 times, most recently from 0153d5f to d67c502 Compare August 24, 2026 15:45
@JPeer264

Copy link
Copy Markdown
Member Author

bugbot run

Comment thread packages/bundler-plugins/src/core/build-plugin-manager.ts
Comment thread packages/bundler-plugins/src/core/cli.ts
Comment thread packages/bundler-plugins/src/core/build-plugin-manager.ts Outdated
@JPeer264
JPeer264 force-pushed the jp/cli-v3-migration branch from 6ddfabf to 27ea586 Compare August 25, 2026 06:23
@JPeer264

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 27ea586. Configure here.

Comment thread packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts
Comment thread packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts
ignoreFile: includeEntry.ignoreFile,
urlPrefix: includeEntry.urlPrefix,
})),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legacy include options are ignored

Medium Severity

uploadLegacySourcemaps only forwards paths, ext, ignore, ignoreFile, and urlPrefix. Public IncludeEntry fields urlSuffix, stripPrefix, stripCommonPrefix, sourceMapReference, rewrite, and validate are dropped. The old upload spread the whole include entry, so existing legacy-upload configs now silently change how files are rewritten and named.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 27ea586. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we need this with the new CLI though.

org: this.#options.org,
project,
url: this.#options.url,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VCS remote option is unused

Medium Severity

release.vcsRemote is still normalized from the option or SENTRY_VSC_REMOTE, but createSentrySDK never receives it. Auto set-commits will use the CLI default remote instead of the configured one, so non-origin remotes fail or attach the wrong repository.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 27ea586. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be prepared here: https://github.com/getsentry/cli/compare/jp/vcs-remote-override?expand=1
We could add this always as a new feature, so it is not blocking for this PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure either but probably worth double checking if we still need any of these

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to double check tbh there are currently no metrics that proof that. It's also kinda an edge case I assume

@JPeer264
JPeer264 marked this pull request as ready for review August 25, 2026 09:38
@JPeer264
JPeer264 requested a review from a team as a code owner August 25, 2026 09:38
@JPeer264
JPeer264 requested review from chargome and nicohrubec and removed request for a team August 25, 2026 09:38
Comment thread packages/bundler-plugins/src/core/cli.ts Outdated
@nicohrubec

nicohrubec commented Aug 27, 2026

Copy link
Copy Markdown
Member

@JPeer264 we merged a nuxt-sourcemaps test yesterday: #23518

so probably fine to remove the one you added here (or merge in case you test additional cases here)

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you actually verify the full ci run takes 4x if we don't use a cli stub? seems like a lot 😅

Comment thread dev-packages/bundler-plugin-integration-tests/fixtures/sentry-stub/index.cjs Outdated
Comment thread dev-packages/e2e-tests/test-applications/nuxt-sourcemaps/assert-build.ts Outdated
Comment thread dev-packages/bundler-plugin-integration-tests/fixtures/sentry-stub/package.json Outdated
Comment thread packages/bundler-plugins/src/core/build-plugin-manager.ts Outdated
Comment thread packages/bundler-plugins/src/core/cli.ts Outdated
Comment thread packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts
org: this.#options.org,
project,
url: this.#options.url,
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure either but probably worth double checking if we still need any of these

Comment thread packages/bundler-plugins/src/core/build-plugin-manager.ts
@JPeer264
JPeer264 force-pushed the jp/cli-v3-migration branch from 0c0b758 to 23a220e Compare August 28, 2026 07:46
Comment thread packages/bundler-plugins/src/core/cli.ts
@JPeer264

JPeer264 commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

did you actually verify the full ci run takes 4x if we don't use a cli stub?

Yes I verified that locally. We can also try to remove the stub entirely and just check if it is getting annoying over time. Those are the stats (now it's even 5x):

Screenshot 2026-08-28 at 10 20 03

@JPeer264
JPeer264 requested a review from nicohrubec August 28, 2026 07:51

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

JPeer264 and others added 11 commits August 28, 2026 13:39
Replace the @sentry/cli v2 binary wrapper with the programmatic SDK
(createSentrySDK) exposed by the new sentry CLI package. A
SentryCliAdapter in src/core/cli.ts maps the plugin's structured option
shapes onto the SDK's typed methods, keeping all translation in one
place:

- release create/finalize/set-commits/deploy and sourcemap upload now
  go through the SDK instead of spawning the CLI binary; one SDK client
  is created per (options, project) pair since project selection is
  bound at client creation time
- the integration-test fixtures replace the @sentry__cli.patch with a
  local sentry-stub fixture recording CLI invocations to
  sentry-cli-mock.json, so upload assertions no longer depend on the
  binary's internals
- remix's release/sourcemap scripts and react-router's buildEnd hook
  are migrated to the same SDK
- add a react-router-7-sourcemaps e2e test app covering the new upload
  path against a mock Sentry server

Requires sentry >= 0.41.0: earlier 0.x builds had a link-fatal named
import of Node 22.15+ zstd builtins in the ESM entry, which crashed the
whole module on Node 18/20.

Co-Authored-By: Claude <noreply@anthropic.com>
The e2e workflow's Playwright setup runs for every test app and fails
with exit 127 when the app cannot resolve @playwright/test, even for
build-only apps that never launch a browser. react-router-sourcemaps
carries the dependency for the same reason.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Nicolas Hrubec <nicolas.hrubec@outlook.com>
…rcemaps

The nuxt-4-sourcemaps app merged in #23518 covers the same ground with more
variants, so keep that one and port over the assertions it did not have:
the release create body, the release finalize call, the chunk-upload options
request, and the release reference plus checksum shape on the assemble body.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cli-v3-migration branch from 23a220e to 8946e63 Compare August 28, 2026 11:39
@JPeer264
JPeer264 merged commit 1cc3bbc into develop Aug 28, 2026
282 checks passed
@JPeer264
JPeer264 deleted the jp/cli-v3-migration branch August 28, 2026 11:57
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.

Update to Sentry CLI v4

2 participants