Skip to content

Commit 08fb932

Browse files
authored
fix(react-router): Ensure source map upload fails silently if Sentry CLI fails (#17081)
Sentry CLI's `cli.releases.uploadSourceMaps` method previously never rejected when the actual CLI binary execution exited with an error code. In CLI 2.49.0 and 2.50.0 I added a new execution mode variant (`rejectOnError`) which continues to pipe stdio to the process (the RR SDKs' upload script) but now also rejects on error. This patch bumps Sentry CLI and configures it to actually reject now. We already catch the rejection and fail silently. Nothing changed here.
1 parent 6829fda commit 08fb932

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
5959
if (sourceMapsUploadOptions?.enabled ?? (true && viteConfig.build.sourcemap !== false)) {
6060
// inject debugIds
6161
try {
62-
await cliInstance.execute(['sourcemaps', 'inject', reactRouterConfig.buildDirectory], debug);
62+
await cliInstance.execute(
63+
['sourcemaps', 'inject', reactRouterConfig.buildDirectory],
64+
debug ? 'rejectOnError' : false,
65+
);
6366
} catch (error) {
6467
// eslint-disable-next-line no-console
6568
console.error('[Sentry] Could not inject debug ids', error);
@@ -73,6 +76,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
7376
paths: [reactRouterConfig.buildDirectory],
7477
},
7578
],
79+
live: 'rejectOnError',
7680
});
7781
} catch (error) {
7882
// eslint-disable-next-line no-console

packages/react-router/test/vite/buildEnd/handleOnBuildEnd.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ describe('sentryOnBuildEnd', () => {
147147

148148
await sentryOnBuildEnd(config);
149149

150+
expect(mockSentryCliInstance.releases.uploadSourceMaps).toHaveBeenCalledTimes(1);
150151
expect(mockSentryCliInstance.releases.uploadSourceMaps).toHaveBeenCalledWith('undefined', {
151152
include: [{ paths: ['/build'] }],
153+
live: 'rejectOnError',
152154
});
153155
});
154156

@@ -249,6 +251,8 @@ describe('sentryOnBuildEnd', () => {
249251
mockSentryCliInstance.execute.mockRejectedValueOnce(new Error('Injection failed'));
250252

251253
await sentryOnBuildEnd(defaultConfig);
254+
expect(mockSentryCliInstance.execute).toHaveBeenCalledTimes(1);
255+
expect(mockSentryCliInstance.execute).toHaveBeenCalledWith(['sourcemaps', 'inject', '/build'], false);
252256

253257
expect(consoleSpy).toHaveBeenCalledWith('[Sentry] Could not inject debug ids', expect.any(Error));
254258
consoleSpy.mockRestore();
@@ -282,6 +286,9 @@ describe('sentryOnBuildEnd', () => {
282286

283287
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('[Sentry] Automatically setting'));
284288
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Deleting asset after upload:'));
289+
// rejectOnError is used in debug mode to pipe debug id injection output from the CLI to this process's stdout
290+
expect(mockSentryCliInstance.execute).toHaveBeenCalledWith(['sourcemaps', 'inject', '/build'], 'rejectOnError');
291+
285292
consoleSpy.mockRestore();
286293
});
287294

yarn.lock

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6924,7 +6924,7 @@
69246924
mitt "^3.0.0"
69256925

69266926
"@sentry-internal/test-utils@link:dev-packages/test-utils":
6927-
version "10.1.0"
6927+
version "10.2.0"
69286928
dependencies:
69296929
express "^4.21.1"
69306930

@@ -6966,41 +6966,81 @@
69666966
magic-string "0.30.8"
69676967
unplugin "1.0.1"
69686968

6969+
6970+
version "2.49.0"
6971+
resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.49.0.tgz#290657e5840b360cb8ca25c8a78f8c0f15c66b03"
6972+
integrity sha512-bgowyDeFuXbjkGq1ZKqcWhmzgfBe7oKIXYWJOOps4+32QfG+YsrdNnottHS01td3bzrJq0QnHj8H12fA81DqrA==
6973+
69696974
69706975
version "2.50.2"
69716976
resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.50.2.tgz#fcf924fcc02cfa54748ff07a380334e533635c74"
69726977
integrity sha512-0Pjpl0vQqKhwuZm19z6AlEF+ds3fJg1KWabv8WzGaSc/fwxMEwjFwOZj+IxWBJPV578cXXNvB39vYjjpCH8j7A==
69736978

6979+
6980+
version "2.49.0"
6981+
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.49.0.tgz#a732004d7131f7e7b44f6a64abdccc36efb35d52"
6982+
integrity sha512-dqxsDUd76aDm03fUwUOs5BR7RHLpSb2EH/B1hlWm0mFvo9uY907XxW9wDFx/qDpCdmpC0aF+lF/lOBOrG9B5Fg==
6983+
69746984
69756985
version "2.50.2"
69766986
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.50.2.tgz#ac9e6dba42095832bac8084abab4b86fdd2956f3"
69776987
integrity sha512-03Cj215M3IdoHAwevCxm5oOm9WICFpuLR05DQnODFCeIUsGvE1pZsc+Gm0Ky/ZArq2PlShBJTpbHvXbCUka+0w==
69786988

6989+
6990+
version "2.49.0"
6991+
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-2.49.0.tgz#73719561510df3369e05e9a4898b4e43b8753e4c"
6992+
integrity sha512-RBDIjIGmNsFw+a6vAt6m3D7ROKsMEB9i3u+UuIRxk0/DyHTcfVWxnK/ScPXGILM6PxQ2XOBfOKad0mmiDHBzZA==
6993+
69796994
69806995
version "2.50.2"
69816996
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-2.50.2.tgz#835acd53ca83f6be9fc0d3d85a3cd4c694051bce"
69826997
integrity sha512-jzFwg9AeeuFAFtoCcyaDEPG05TU02uOy1nAX09c1g7FtsyQlPcbhI94JQGmnPzdRjjDmORtwIUiVZQrVTkDM7w==
69836998

6999+
7000+
version "2.49.0"
7001+
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-2.49.0.tgz#8d1bb1378251a3aa995cc4b56bd352fa12a84b66"
7002+
integrity sha512-gDAd5/vJbEhd4Waud0Cd8ZRqLEagDlOvWwNH3KB694EiHJUwzRSiTA1YUVMYGI8Z9UyEA1sKxARwm2Trv99BxA==
7003+
69847004
69857005
version "2.50.2"
69867006
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-2.50.2.tgz#72f0e4bc1c515754aa11225efce711a24fb53524"
69877007
integrity sha512-J+POvB34uVyHbIYF++Bc/OCLw+gqKW0H/y/mY7rRZCiocgpk266M4NtsOBl6bEaurMx1D+BCIEjr4nc01I/rqA==
69887008

7009+
7010+
version "2.49.0"
7011+
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-2.49.0.tgz#7bf58fb7005c89fdde4e1262d5ed35e23065aceb"
7012+
integrity sha512-mbohGvPNhHjUciYNXzkt9TYUebTmxeAp9v9JfLSb/Soz6fubKwEHhpRJuz1zASxVWIR4PuqkePchqN5zhcLC0A==
7013+
69897014
69907015
version "2.50.2"
69917016
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-2.50.2.tgz#d06f8ffd65871b1373a0d2228ab254d9456a615c"
69927017
integrity sha512-81yQVRLj8rnuHoYcrM7QbOw8ubA3weiMdPtTxTim1s6WExmPgnPTKxLCr9xzxGJxFdYo3xIOhtf5JFpUX/3j4A==
69937018

7019+
7020+
version "2.49.0"
7021+
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-arm64/-/cli-win32-arm64-2.49.0.tgz#2bf6dd911acbe3ddb02eec0afb4301bb8fb25b53"
7022+
integrity sha512-3zwvsp61EPpSuGpGdXY4JelVJmNEjoj4vn5m6EFoOtk7OUI5/VFqqR4wchjy9Hjm3Eh6MB5K+KTKXs4W2p18ng==
7023+
69947024
69957025
version "2.50.2"
69967026
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-arm64/-/cli-win32-arm64-2.50.2.tgz#4bd7a140367c17f77d621903cfe0914232108657"
69977027
integrity sha512-QjentLGvpibgiZlmlV9ifZyxV73lnGH6pFZWU5wLeRiaYKxWtNrrHpVs+HiWlRhkwQ0mG1/S40PGNgJ20DJ3gA==
69987028

7029+
7030+
version "2.49.0"
7031+
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-2.49.0.tgz#32e31472ae6c5f69e538a4061d651937fcb8f14a"
7032+
integrity sha512-2oWaNl6z0BaOCAjM1Jxequfgjod3XO6wothxow4kA8e9+43JLhgarSdpwJPgQjcVyxjygwQ3/jKPdUFh0qNOmg==
7033+
69997034
70007035
version "2.50.2"
70017036
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-2.50.2.tgz#1eb997cf780c396446cdd8e63c6d4309894465e8"
70027037
integrity sha512-UkBIIzkQkQ1UkjQX8kHm/+e7IxnEhK6CdgSjFyNlxkwALjDWHJjMztevqAPz3kv4LdM6q1MxpQ/mOqXICNhEGg==
70037038

7039+
7040+
version "2.49.0"
7041+
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-2.49.0.tgz#86aab38cb41f885914d7c99ceaab7b6ce52c72c6"
7042+
integrity sha512-dR4ulyrA6ZT7x7cg4Rwm0tcHf4TZz5QO6t1W1jX6uJ9n/U0bOSqSFZHNf/RryiUzQE1g8LBthOYyKGMkET6T8w==
7043+
70047044
70057045
version "2.50.2"
70067046
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-2.50.2.tgz#1d0c106125b6dc87f3a598ac02519c699f17a6c0"
@@ -28567,7 +28607,6 @@ [email protected], stylus@^0.59.0:
2856728607

2856828608
sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills:
2856928609
version "3.36.0"
28570-
uid fd682f6129e507c00bb4e6319cc5d6b767e36061
2857128610
resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061"
2857228611
dependencies:
2857328612
"@jridgewell/gen-mapping" "^0.3.2"

0 commit comments

Comments
 (0)