Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@opentelemetry/instrumentation": "^0.208.0",
"@opentelemetry/semantic-conventions": "^1.37.0",
"@sentry/browser": "10.30.0",
"@sentry/cli": "^2.58.4",
"@sentry/cli": "^3.0.0",
"@sentry/core": "10.30.0",
"@sentry/node": "10.30.0",
"@sentry/react": "10.30.0",
Expand Down
10 changes: 3 additions & 7 deletions packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rm } from 'node:fs/promises';
import type { Config } from '@react-router/dev/config';
import SentryCli from '@sentry/cli';
import { SentryCli } from '@sentry/cli';
import type { SentryVitePluginOptions } from '@sentry/vite-plugin';
import { glob } from 'glob';
import type { SentryReactRouterBuildOptions } from '../types';
Expand Down Expand Up @@ -73,7 +73,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
// check if release should be created
if (release?.name) {
try {
await cliInstance.releases.new(release.name);
await cliInstance.releases.new(release.name, {});
} catch (error) {
// eslint-disable-next-line no-console
console.error('[Sentry] Could not create release', error);
Expand All @@ -83,10 +83,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
if (!sourcemaps?.disable && viteConfig.build.sourcemap !== false) {
// inject debugIds
try {
await cliInstance.execute(
['sourcemaps', 'inject', reactRouterConfig.buildDirectory],
debug ? 'rejectOnError' : false,
);
await cliInstance.execute(['sourcemaps', 'inject', reactRouterConfig.buildDirectory], debug);
} catch (error) {
// eslint-disable-next-line no-console
console.error('[Sentry] Could not inject debug ids', error);
Expand All @@ -100,7 +97,6 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
paths: [reactRouterConfig.buildDirectory],
},
],
live: 'rejectOnError',
});
} catch (error) {
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SentryCli from '@sentry/cli';
import { SentryCli } from '@sentry/cli';
import * as fs from 'fs';
import { glob } from 'glob';
import type { ResolvedConfig } from 'vite';
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('sentryOnBuildEnd', () => {
// @ts-expect-error - mocking the React config
await sentryOnBuildEnd(config);

expect(mockSentryCliInstance.releases.new).toHaveBeenCalledWith('v1.0.0');
expect(mockSentryCliInstance.releases.new).toHaveBeenCalledWith('v1.0.0', {});
});

it('should create a new Sentry release when release name is provided in unstable_sentryVitePluginOptions', async () => {
Expand All @@ -106,7 +106,7 @@ describe('sentryOnBuildEnd', () => {
// @ts-expect-error - mocking the React config
await sentryOnBuildEnd(config);

expect(mockSentryCliInstance.releases.new).toHaveBeenCalledWith('v1.0.0-unstable');
expect(mockSentryCliInstance.releases.new).toHaveBeenCalledWith('v1.0.0-unstable', {});
});

it('should prioritize release name from main config over unstable_sentryVitePluginOptions', async () => {
Expand All @@ -131,7 +131,7 @@ describe('sentryOnBuildEnd', () => {
// @ts-expect-error - mocking the React config
await sentryOnBuildEnd(config);

expect(mockSentryCliInstance.releases.new).toHaveBeenCalledWith('v1.0.0');
expect(mockSentryCliInstance.releases.new).toHaveBeenCalledWith('v1.0.0', {});
});

it('should upload source maps when enabled', async () => {
Expand All @@ -154,7 +154,6 @@ describe('sentryOnBuildEnd', () => {
expect(mockSentryCliInstance.releases.uploadSourceMaps).toHaveBeenCalledTimes(1);
expect(mockSentryCliInstance.releases.uploadSourceMaps).toHaveBeenCalledWith('undefined', {
include: [{ paths: ['/build'] }],
live: 'rejectOnError',
});
});

Expand Down Expand Up @@ -298,8 +297,7 @@ describe('sentryOnBuildEnd', () => {

expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('[Sentry] Automatically setting'));
expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Deleting asset after upload:'));
// rejectOnError is used in debug mode to pipe debug id injection output from the CLI to this process's stdout
expect(mockSentryCliInstance.execute).toHaveBeenCalledWith(['sourcemaps', 'inject', '/build'], 'rejectOnError');
expect(mockSentryCliInstance.execute).toHaveBeenCalledWith(['sourcemaps', 'inject', '/build'], true);

consoleSpy.mockRestore();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"@opentelemetry/instrumentation": "^0.208.0",
"@opentelemetry/semantic-conventions": "^1.37.0",
"@remix-run/router": "1.x",
"@sentry/cli": "^2.58.2",
"@sentry/cli": "^3.0.0",
"@sentry/core": "10.30.0",
"@sentry/node": "10.30.0",
"@sentry/react": "10.30.0",
Expand Down
7 changes: 3 additions & 4 deletions packages/remix/scripts/createRelease.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
/* eslint-disable no-console */
const SentryCli = require('@sentry/cli');
const { SentryCli } = require('@sentry/cli');

Copy link

Choose a reason for hiding this comment

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

Bug: The Remix createRelease.js script uses outdated Sentry CLI v3 API calls for creating releases and uploading source maps, which will cause runtime failures.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The script packages/remix/scripts/createRelease.js was only partially migrated to support Sentry CLI v3. The call to sentry.releases.new(release) is incorrect, as the v3 API expects two arguments, like releases.new(release.name, {}). Additionally, the uploadSourceMaps() function is called with a live: 'rejectOnError' option, which was removed in v3. These outdated API calls, which contrast with the correctly updated react-router package in the same pull request, will cause the Remix release script to fail at runtime.

💡 Suggested Fix

Update packages/remix/scripts/createRelease.js to use the correct Sentry CLI v3 API. Change the sentry.releases.new(release) call to sentry.releases.new(release.name, {}). Remove the deprecated live: 'rejectOnError' option from the uploadSourceMaps() call, aligning the implementation with the react-router package.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: packages/remix/scripts/createRelease.js#L3

Potential issue: The script `packages/remix/scripts/createRelease.js` was only partially
migrated to support Sentry CLI v3. The call to `sentry.releases.new(release)` is
incorrect, as the v3 API expects two arguments, like `releases.new(release.name, {})`.
Additionally, the `uploadSourceMaps()` function is called with a `live: 'rejectOnError'`
option, which was removed in v3. These outdated API calls, which contrast with the
correctly updated `react-router` package in the same pull request, will cause the Remix
release script to fail at runtime.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 7522976

Copy link
Member Author

Choose a reason for hiding this comment

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

Added // @ts-check in order to see the changes in the future

const { deleteSourcemaps } = require('./deleteSourcemaps');

Expand All @@ -25,14 +26,12 @@ async function createRelease(argv, URL_PREFIX, BUILD_PATH) {
release = argv.release;
}

await sentry.releases.new(release);
await sentry.releases.new(release, {});

try {
await sentry.releases.uploadSourceMaps(release, {
urlPrefix: URL_PREFIX,
include: [BUILD_PATH],
useArtifactBundle: !argv.disableDebugIds,
live: 'rejectOnError',
});
} catch {
console.warn('[sentry] Failed to upload sourcemaps.');
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/scripts/injectDebugId.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
const { execSync } = require('child_process');

const SentryCli = require('@sentry/cli');
const { SentryCli } = require('@sentry/cli');

function injectDebugId(buildPath) {
const cliPath = SentryCli.getPath();
Expand Down
7 changes: 3 additions & 4 deletions packages/remix/test/scripts/upload-sourcemaps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ async function mock(mockedUri: string, stub: any) {
}

await vi.hoisted(async () =>
mock(
'@sentry/cli',
vi.fn().mockImplementation(() => {
mock('@sentry/cli', {
SentryCli: vi.fn().mockImplementation(() => {
return {
execute: vi.fn(),
releases: {
Expand All @@ -35,7 +34,7 @@ await vi.hoisted(async () =>
},
};
}),
),
}),
);

// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
66 changes: 65 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7093,42 +7093,82 @@
resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.58.4.tgz#5e3005c1f845acac243e8dcb23bef17337924768"
integrity sha512-kbTD+P4X8O+nsNwPxCywtj3q22ecyRHWff98rdcmtRrvwz8CKi/T4Jxn/fnn2i4VEchy08OWBuZAqaA5Kh2hRQ==

"@sentry/cli-darwin@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-3.0.0.tgz#a87c084faed6a28f2eec3182e627538eb8ff4019"
integrity sha512-Tni8jovMpYdSpppzviBSeVwLmIRIb2msHtf+hVQhuSqOEf2ZjhUNeeitjYc0qzeqYyI5Gr3jVX7ZTWDpUXDbWA==

"@sentry/cli-linux-arm64@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.58.4.tgz#69da57656fda863f255d92123c3a3437e470408e"
integrity sha512-0g0KwsOozkLtzN8/0+oMZoOuQ0o7W6O+hx+ydVU1bktaMGKEJLMAWxOQNjsh1TcBbNIXVOKM/I8l0ROhaAb8Ig==

"@sentry/cli-linux-arm64@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm64/-/cli-linux-arm64-3.0.0.tgz#531e115e14dac7dc700a67309157c9f600f3059e"
integrity sha512-apfuZz5OgJbJ6YWszADoekt7PS+JOtE4EQgGaB951FZbBongSmGUbWscXuv3p2L4IbrewMoZLQvFQU0vMBN1ZA==

"@sentry/cli-linux-arm@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-2.58.4.tgz#869ddab30f0dcebc0e61cff2f3ff47dcd40f8abe"
integrity sha512-rdQ8beTwnN48hv7iV7e7ZKucPec5NJkRdrrycMJMZlzGBPi56LqnclgsHySJ6Kfq506A2MNuQnKGaf/sBC9REA==

"@sentry/cli-linux-arm@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-arm/-/cli-linux-arm-3.0.0.tgz#0d6cfc1ad8fc626336c0483e0d8e9e0648d89bc6"
integrity sha512-yRSj6rMiHqwneWky6Zlv7SyLRvZM8WtfJLVFA7NWpPTUIAkt6d9h4rxlQE1m47WHfkiV7sE9w2ggnhSyvRCeJw==

"@sentry/cli-linux-i686@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-2.58.4.tgz#e30ca6b897147b3fb7b2e8684b139183d55e21c6"
integrity sha512-NseoIQAFtkziHyjZNPTu1Gm1opeQHt7Wm1LbLrGWVIRvUOzlslO9/8i6wETUZ6TjlQxBVRgd3Q0lRBG2A8rFYA==

"@sentry/cli-linux-i686@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-i686/-/cli-linux-i686-3.0.0.tgz#633a1241853f6940d5e29bfe6a1a87ed527ff4e0"
integrity sha512-i3eOPXenym1b92s7hceQmKrJytJSpYKl6mbDRbFkpdPYy7yfyQJHVKMoAlZWMa3zdTvAOcfhCi6NObF41T/6Iw==

"@sentry/cli-linux-x64@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-2.58.4.tgz#f667e1fcaf0860f15401af8e0ee72f5013d84458"
integrity sha512-d3Arz+OO/wJYTqCYlSN3Ktm+W8rynQ/IMtSZLK8nu0ryh5mJOh+9XlXY6oDXw4YlsM8qCRrNquR8iEI1Y/IH+Q==

"@sentry/cli-linux-x64@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-linux-x64/-/cli-linux-x64-3.0.0.tgz#ad156cf77bddb5164e5457f12f2a0ef03e1fdaa8"
integrity sha512-KswI4val260rNc6eHsRuU2MHFGLMkbOcsacUggRZWlyZYccMHiK+IfKBxZJLAA5ti8Zr/68Sbvgfd+FvwHKeXQ==

"@sentry/cli-win32-arm64@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-arm64/-/cli-win32-arm64-2.58.4.tgz#f612c5788954e2a97b6626e9e46fa9a41cb049c1"
integrity sha512-bqYrF43+jXdDBh0f8HIJU3tbvlOFtGyRjHB8AoRuMQv9TEDUfENZyCelhdjA+KwDKYl48R1Yasb4EHNzsoO83w==

"@sentry/cli-win32-arm64@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-arm64/-/cli-win32-arm64-3.0.0.tgz#82ccf03d04c7560daf6d6a089d02c2b27c74582e"
integrity sha512-DhqSwh6hJfUd2XVOEEaeI30FE0CgAJGIrDWy6gw2PV2akr5KPp/Wm9gkKsutFrhxQyFEnbSEiwG0hT4G7zKsbg==

"@sentry/cli-win32-i686@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-2.58.4.tgz#5611c05499f1b959d23e37650d0621d299c49cfc"
integrity sha512-3triFD6jyvhVcXOmGyttf+deKZcC1tURdhnmDUIBkiDPJKGT/N5xa4qAtHJlAB/h8L9jgYih9bvJnvvFVM7yug==

"@sentry/cli-win32-i686@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-i686/-/cli-win32-i686-3.0.0.tgz#5773df876bf294a249ed78f6179c62da0da1bd7b"
integrity sha512-yrcuP4+2eNA2tFU/J+HvMWf/zNeXEJZoB/L+ds2f7w8Zs0oubmCxufE2oeoQhwcNDLD4xJhjSKorYS/Sn51FXg==

"@sentry/cli-win32-x64@2.58.4":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-2.58.4.tgz#3290c59399579e8d484c97246cfa720171241061"
integrity sha512-cSzN4PjM1RsCZ4pxMjI0VI7yNCkxiJ5jmWncyiwHXGiXrV1eXYdQ3n1LhUYLZ91CafyprR0OhDcE+RVZ26Qb5w==

"@sentry/cli@^2.57.0", "@sentry/cli@^2.58.2", "@sentry/cli@^2.58.4":
"@sentry/cli-win32-x64@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli-win32-x64/-/cli-win32-x64-3.0.0.tgz#eb9ef00a1dea73dd96e2ea99a4f1233085eec6bf"
integrity sha512-wa0RDRCgEoggEQ5TGx1zYBOIoms9xb5RxbbLGN2TH3EBiIOKOZrHVQjczDgBHQrtlyxwN0vTLjM3690kJ+gq+Q==

"@sentry/cli@^2.57.0":
version "2.58.4"
resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.58.4.tgz#eb8792600cdf956cc4fe2bf51380ea1682327411"
integrity sha512-ArDrpuS8JtDYEvwGleVE+FgR+qHaOp77IgdGSacz6SZy6Lv90uX0Nu4UrHCQJz8/xwIcNxSqnN22lq0dH4IqTg==
Expand All @@ -7148,6 +7188,25 @@
"@sentry/cli-win32-i686" "2.58.4"
"@sentry/cli-win32-x64" "2.58.4"

"@sentry/cli@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-3.0.0.tgz#cfdf5996d6925f373d541601a487aaaf36a6fae5"
integrity sha512-w/wH9tPlZY98mP+a0gYhTvuyRXnPrZa0hYaJnuaBNf9s2x+u7iz8tgtF4fW9X8DNeFylHxqZzSMK/gDLo5IAsA==
dependencies:
progress "^2.0.3"
proxy-from-env "^1.1.0"
undici "^6.22.0"
which "^2.0.2"
optionalDependencies:
"@sentry/cli-darwin" "3.0.0"
"@sentry/cli-linux-arm" "3.0.0"
"@sentry/cli-linux-arm64" "3.0.0"
"@sentry/cli-linux-i686" "3.0.0"
"@sentry/cli-linux-x64" "3.0.0"
"@sentry/cli-win32-arm64" "3.0.0"
"@sentry/cli-win32-i686" "3.0.0"
"@sentry/cli-win32-x64" "3.0.0"

"@sentry/rollup-plugin@^4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@sentry/rollup-plugin/-/rollup-plugin-4.6.1.tgz#28dece8d6fad3044fd634724f6334f6b9b8f3ded"
Expand Down Expand Up @@ -30204,6 +30263,11 @@ undici@^6.11.1, undici@^6.19.2:
resolved "https://registry.yarnpkg.com/undici/-/undici-6.21.3.tgz#185752ad92c3d0efe7a7d1f6854a50f83b552d7a"
integrity sha512-gBLkYIlEnSp8pFbT64yFgGE6UIB9tAkhukC23PmMDCe5Nd+cRqKxSjw5y54MK2AZMgZfJWMaNE4nYUHgi1XEOw==

undici@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/undici/-/undici-6.22.0.tgz#281adbc157af41da8e75393c9d75a1b788811bc3"
integrity sha512-hU/10obOIu62MGYjdskASR3CUAiYaFTtC9Pa6vHyf//mAipSvSQg6od2CnJswq7fvzNS3zJhxoRkgNVaHurWKw==

unenv@2.0.0-rc.17:
version "2.0.0-rc.17"
resolved "https://registry.yarnpkg.com/unenv/-/unenv-2.0.0-rc.17.tgz#fa9b80d30e16f73e2d4a0be568ca97c0fb76bdac"
Expand Down
Loading