-
-
Notifications
You must be signed in to change notification settings - Fork 236
chore(js): Remove live = 'rejectOnError' option
#2971
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
base: szokeasaurusrex/no-release-bundle-uploads
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,11 +281,10 @@ function getPath() { | |
| * expect(output.trim()).toBe('sentry-cli x.y.z'); | ||
| * | ||
| * @param {string[]} args Command line arguments passed to `sentry-cli`. | ||
| * @param {boolean | 'rejectOnError'} live can be set to: | ||
| * - `true` to inherit stdio to display `sentry-cli` output directly. | ||
| * - `false` to not inherit stdio and return the output as a string. | ||
| * - `'rejectOnError'` to inherit stdio and reject the promise if the command | ||
| * @param {boolean} live can be set to: | ||
| * - `true` to inherit stdio and reject the promise if the command | ||
| * exits with a non-zero exit code. | ||
| * - `false` to not inherit stdio and return the output as a string. | ||
| * @param {boolean} silent Disable stdout for silents build (CI/Webpack Stats, ...) | ||
| * @param {string} [configFile] Relative or absolute path to the configuration file. | ||
| * @param {import('./index').SentryCliOptions} [config] More configuration to pass to the CLI | ||
|
|
@@ -325,26 +324,18 @@ async function execute(args, live, silent, configFile, config = {}) { | |
| } | ||
|
|
||
| return new Promise((resolve, reject) => { | ||
| if (live === true || live === 'rejectOnError') { | ||
| if (live) { | ||
| const output = silent ? 'ignore' : 'inherit'; | ||
| const pid = childProcess.spawn(getPath(), args, { | ||
| env, | ||
| // stdin, stdout, stderr | ||
| stdio: ['ignore', output, output], | ||
| }); | ||
| pid.on('exit', (exitCode) => { | ||
| if (live === 'rejectOnError') { | ||
| if (exitCode === 0) { | ||
| resolve('success (live mode)'); | ||
| } | ||
| reject(new Error(`Command ${args.join(' ')} failed with exit code ${exitCode}`)); | ||
| if (exitCode === 0) { | ||
| resolve('success (live mode)'); | ||
| } | ||
| // According to the type definition, resolving with void is not allowed. | ||
| // However, for backwards compatibility, we resolve void here to | ||
| // avoid a behaviour-breaking change. | ||
| // TODO (v3): Clean this up and always resolve a string (or change the type definition) | ||
| // @ts-expect-error - see comment above | ||
| resolve(); | ||
| reject(new Error(`Command ${args.join(' ')} failed with exit code ${exitCode}`)); | ||
|
Comment on lines
+335
to
+338
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. Bug: The 🔍 Detailed AnalysisThe 💡 Suggested FixPlace the 🤖 Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
| }); | ||
| } else { | ||
| childProcess.execFile(getPath(), args, { env }, (err, stdout) => { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,11 +142,10 @@ class Releases { | |
| * ext: ['js', 'map', 'jsbundle', 'bundle'], // override file extensions to scan for | ||
| * projects: ['node'], // provide a list of projects | ||
| * decompress: false // decompress gzip files before uploading | ||
| * live: true // whether to inherit stdio to display `sentry-cli` output directly. | ||
| * }); | ||
| * | ||
| * @param {string} release Unique name of the release. | ||
| * @param {SentryCliUploadSourceMapsOptions & {live?: boolean | 'rejectOnError'}} options Options to configure the source map upload. | ||
| * @param {SentryCliUploadSourceMapsOptions} options Options to configure the source map upload. | ||
|
Member
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. @szokeasaurusrex Here the
Member
Author
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. Yes, exactly, this removal is intentional. For sourcemaps upload, we always use |
||
| * @returns {Promise<string[]>} A promise that resolves when the upload has completed successfully. | ||
| * @memberof SentryReleases | ||
| */ | ||
|
|
@@ -193,10 +192,7 @@ class Releases { | |
|
|
||
| return uploadPaths.map((path) => | ||
| // `execute()` is async and thus we're returning a promise here | ||
| this.execute( | ||
| helper.prepareCommand([...args, path], SOURCEMAPS_SCHEMA, newOptions), | ||
| options.live != null ? options.live : true | ||
| ) | ||
| this.execute(helper.prepareCommand([...args, path], SOURCEMAPS_SCHEMA, newOptions), true) | ||
| ); | ||
| }); | ||
|
|
||
|
|
@@ -252,11 +248,10 @@ class Releases { | |
| /** | ||
| * See {helper.execute} docs. | ||
| * @param {string[]} args Command line arguments passed to `sentry-cli`. | ||
| * @param {boolean | 'rejectOnError'} live can be set to: | ||
| * - `true` to inherit stdio to display `sentry-cli` output directly. | ||
| * - `false` to not inherit stdio and return the output as a string. | ||
| * - `'rejectOnError'` to inherit stdio and reject the promise if the command | ||
| * @param {boolean} live can be set to: | ||
| * - `true` to inherit stdio and reject the promise if the command | ||
| * exits with a non-zero exit code. | ||
| * - `false` to not inherit stdio and return the output as a string. | ||
| * @returns {Promise<string>} A promise that resolves to the standard output. | ||
| */ | ||
| async execute(args, live) { | ||
|
|
||
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.
Bug: Missing else causes reject after successful resolve
The exit handler unconditionally calls
reject()after conditionally callingresolve()for zero exit codes. WhenexitCode === 0, bothresolve('success (live mode)')andreject(new Error(...))execute sequentially. While promises only settle once, this creates an unhandled rejection and indicates incorrect control flow logic. Anelseclause orreturnstatement is needed to prevent rejection after successful resolution.