@@ -14,6 +14,7 @@ import {
1414import type { SentryContext } from "../../context.js" ;
1515import {
1616 type ArtifactFile ,
17+ DEFAULT_UPLOAD_MAX_WAIT_MS ,
1718 uploadSourcemaps ,
1819} from "../../lib/api/sourcemaps.js" ;
1920import { isCi } from "../../lib/ci.js" ;
@@ -78,6 +79,26 @@ function formatUploadResult(data: UploadCommandResult): string {
7879
7980const usageHint = ( ) => sentry `sourcemap upload <directory>` ;
8081
82+ /**
83+ * Parse `--wait[=seconds]` into a wait limit in milliseconds.
84+ *
85+ * Bare `--wait` parses `""` and keeps the default limit. `--wait=0` waits
86+ * with no limit.
87+ */
88+ export function parseWaitLimit ( input : string ) : number {
89+ if ( input === "" ) {
90+ return DEFAULT_UPLOAD_MAX_WAIT_MS ;
91+ }
92+ const seconds = Number ( input ) ;
93+ if ( ! Number . isInteger ( seconds ) || seconds < 0 ) {
94+ throw new ValidationError (
95+ `--wait takes a whole number of seconds (got "${ input } "). Use --wait=0 to wait with no limit.` ,
96+ "wait" ,
97+ ) ;
98+ }
99+ return seconds === 0 ? Number . POSITIVE_INFINITY : seconds * 1000 ;
100+ }
101+
81102/**
82103 * Compute the longest common directory prefix across a list of paths.
83104 *
@@ -228,7 +249,8 @@ export const uploadCommand = buildCommand({
228249 "In CI, the command waits up to five minutes for Sentry to finish " +
229250 "processing the upload and exits with an error if processing fails. " +
230251 "Elsewhere it exits once Sentry accepts the upload. Pass --wait or " +
231- "--no-wait to override." ,
252+ "--no-wait to override, and --wait=<seconds> to change the limit " +
253+ "(--wait=0 waits with no limit). The value must be attached with =." ,
232254 examples : [
233255 {
234256 description : "Upload sourcemaps from dist/" ,
@@ -266,6 +288,10 @@ export const uploadCommand = buildCommand({
266288 description : "Wait for Sentry to process the upload outside CI" ,
267289 run : "sourcemap upload ./dist --wait" ,
268290 } ,
291+ {
292+ description : "Wait up to ten minutes for processing" ,
293+ run : "sourcemap upload ./dist --wait=600" ,
294+ } ,
269295 ] ,
270296 } ,
271297 output : {
@@ -350,12 +376,20 @@ export const uploadCommand = buildCommand({
350376 default : false ,
351377 } ,
352378 wait : {
353- kind : "boolean" ,
379+ kind : "parsed" ,
380+ parse : parseWaitLimit ,
354381 brief :
355- "Wait up to five minutes for the server to fully process the " +
356- "uploaded files (default: on in CI)" ,
382+ "Wait for the server to fully process the uploaded files, up to " +
383+ "the given seconds (default: 300, 0 = no limit; on in CI)" ,
384+ placeholder : "seconds" ,
357385 optional : true ,
358- withNegated : true ,
386+ inlineOnly : true ,
387+ } ,
388+ "no-wait" : {
389+ kind : "boolean" ,
390+ brief : "Exit once Sentry accepts the upload, even in CI" ,
391+ optional : true ,
392+ default : false ,
359393 } ,
360394 } ,
361395 } ,
@@ -372,12 +406,26 @@ export const uploadCommand = buildCommand({
372406 "strip-common-prefix" ?: boolean ;
373407 "no-rewrite" ?: boolean ;
374408 "allow-empty" ?: boolean ;
375- wait ?: boolean ;
409+ wait ?: number | string ;
410+ "no-wait" ?: boolean ;
376411 } ,
377412 dir : string ,
378413 ) {
414+ if ( flags . wait !== undefined && flags [ "no-wait" ] ) {
415+ throw new ValidationError (
416+ "--wait and --no-wait cannot be used together." ,
417+ "wait" ,
418+ ) ;
419+ }
379420 // CI must fail when Sentry rejects the bundle, so wait there by default.
380- const wait = flags . wait ?? isCi ( this . env ) ;
421+ const wait = flags [ "no-wait" ]
422+ ? false
423+ : flags . wait !== undefined || isCi ( this . env ) ;
424+ // SDK callers supply the public string form without Stricli parsing.
425+ const maxWaitMs =
426+ typeof flags . wait === "string"
427+ ? parseWaitLimit ( flags . wait )
428+ : ( flags . wait ?? DEFAULT_UPLOAD_MAX_WAIT_MS ) ;
381429
382430 // Validate the directory and discover pairs read-only first so we
383431 // don't write debug IDs when the upload won't proceed (empty dir,
@@ -497,6 +545,7 @@ export const uploadCommand = buildCommand({
497545 dist : flags . dist ,
498546 files : artifactFiles ,
499547 wait,
548+ maxWaitMs,
500549 } ) ;
501550
502551 // Count actually-uploaded pairs (one minified_source entry per pair).
0 commit comments