Skip to content

Commit 038b956

Browse files
feat(cli): Take the sourcemap upload wait limit as --wait=<seconds>
Bare `--wait` keeps the five-minute default and never consumes the next argument, so `--wait ./dist` still reads `./dist` as the directory. `--wait=600` sets the limit and `--wait=0` waits with no limit. Stricli has no flag that takes a value only when it is attached with `=`, so the @stricli/core patch adds an `inlineOnly` option for parsed flags. Help, docs, and shell completion treat such a flag as taking no spaced value. `--no-wait` is now its own boolean flag. Co-Authored-By: BYK <burak.kaya@sentry.io>
1 parent db5c702 commit 038b956

13 files changed

Lines changed: 348 additions & 93 deletions

File tree

‎apps/cli-docs/src/content/docs/migrating-from-v3.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,16 @@ Two behavioral differences to be aware of:
571571
`--strip-common-prefix`, `--no-rewrite`, `--allow-empty`, `--wait`. These
572572
v3 flags are
573573
**not present** in v4: `--url-suffix`, `--note`, `--validate`, `--decompress`,
574-
`--wait-for`, `--no-sourcemap-reference`, `--debug-id-reference`,
574+
`--wait-for` (use `--wait=<seconds>`), `--no-sourcemap-reference`, `--debug-id-reference`,
575575
`--bundle`, `--bundle-sourcemap`, `--strict`. `sourcemap inject` also drops
576576
`--release`. Run `sentry sourcemap upload --help` for the current set.
577577
- **`--wait` is on by default in CI:** when a CI environment variable such as
578578
`CI` or `GITHUB_ACTIONS` is set, `sourcemap upload` waits up to five minutes
579579
for Sentry to process the upload and exits with an error if processing
580580
fails or times out. Pass `--no-wait` to return as soon as Sentry accepts the
581-
upload, or `--wait` to wait outside CI. The five-minute limit is fixed, so
582-
drop v3's `--wait-for`.
581+
upload, or `--wait` to wait outside CI. Replace v3's `--wait-for 600` with
582+
`--wait=600`; `--wait=0` waits with no limit. The value must be attached
583+
with `=`, because `--wait 600` reads `600` as the directory.
583584
- **`--debug-id-reference` is now automatic:** in v3 that flag let `sourcemaps
584585
upload` take the debug ID from the linked sourcemap when it couldn't verify
585586
one in the bundle itself, for example in binary bundles.

‎apps/cli-docs/src/fragments/commands/sourcemap.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ Sentry processes an upload after it accepts it, and processing can still
4343
fail. In CI, `sentry sourcemap upload` waits up to five minutes for
4444
processing to finish and exits with an error if it fails or times out.
4545
Outside CI it exits once Sentry accepts the upload. Pass `--wait` or
46-
`--no-wait` to choose.
46+
`--no-wait` to choose, and `--wait=<seconds>` to change the limit
47+
(`--wait=0` waits with no limit). Attach the value with `=`: `--wait 600`
48+
reads `600` as the directory.

‎packages/cli/patches/@stricli%2Fcore@1.2.8.patch‎

Lines changed: 122 additions & 30 deletions
Large diffs are not rendered by default.

‎packages/cli/plugins/sentry-cli/skills/sentry-cli/references/sourcemap.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ Upload sourcemaps to Sentry
6565
- `--strip-common-prefix - Automatically strip the longest common path prefix from all files`
6666
- `--no-rewrite - Upload files as-is without injecting debug IDs`
6767
- `--allow-empty - Exit successfully when no JS + sourcemap pairs are found (default: error out to catch silent build misconfigurations)`
68-
- `--wait - Wait up to five minutes for the server to fully process the uploaded files (default: on in CI)`
68+
- `--wait[=<value>] - Wait for the server to fully process the uploaded files, up to the given seconds (default: 300, 0 = no limit; on in CI)`
69+
- `--no-wait - Exit once Sentry accepts the upload, even in CI`
6970

7071
**Examples:**
7172

@@ -96,6 +97,9 @@ sentry sourcemap upload ./dist --ext .js,.mjs
9697

9798
# Wait for Sentry to process the upload outside CI
9899
sentry sourcemap upload ./dist --wait
100+
101+
# Wait up to ten minutes for processing
102+
sentry sourcemap upload ./dist --wait=600
99103
```
100104

101105
### `sentry sourcemap resolve <directory>`

‎packages/cli/script/check-patches.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ for (const [key, patchPath] of Object.entries(patches)) {
244244
* `-v`=version alias in `runApplication` so `-v` stays the Sentry CLI's
245245
* `--verbose` alias at every position; `--version` remains the version flag.
246246
* The stale marker is the original `inputs[0] === "-v"` version check.
247+
*
248+
* @stricli/core (`inlineOnly` parsed flags): the patch lets a parsed flag take
249+
* its value only as `--flag=value`, so bare `--wait` never consumes the next
250+
* argument. Pure insertion, guarded by the `inlineOnly` required marker. Its
251+
* absence means `sourcemap upload --wait ./dist` reads `./dist` as the limit.
247252
*/
248253
const CONTENT_ASSERTIONS: ReadonlyArray<{
249254
/** Installed file to inspect, relative to the resolved node_modules dir. */
@@ -318,6 +323,18 @@ const CONTENT_ASSERTIONS: ReadonlyArray<{
318323
description:
319324
"@stricli/core CJS: pluggable `renderHelp` hook missing (`sentry --help --json` will fall back to text help instead of structured JSON)",
320325
},
326+
{
327+
file: "@stricli/core/dist/index.js",
328+
requiredMarker: "inlineOnly",
329+
description:
330+
"@stricli/core ESM: `inlineOnly` flag scanning missing (`sentry sourcemap upload --wait ./dist` will read `./dist` as the wait limit)",
331+
},
332+
{
333+
file: "@stricli/core/dist/index.cjs",
334+
requiredMarker: "inlineOnly",
335+
description:
336+
"@stricli/core CJS: `inlineOnly` flag scanning missing (`sentry sourcemap upload --wait ./dist` will read `./dist` as the wait limit)",
337+
},
321338
];
322339

323340
for (const assertion of CONTENT_ASSERTIONS) {

‎packages/cli/script/generate-command-docs.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ function formatFlagRow(
9999
if (alias) {
100100
syntax = `-${alias}, ${syntax}`;
101101
}
102-
if ((flag.kind === "parsed" || flag.kind === "enum") && !flag.variadic) {
102+
if (flag.inlineOnly) {
103+
syntax += `[=<${flag.name}>]`;
104+
} else if (
105+
(flag.kind === "parsed" || flag.kind === "enum") &&
106+
!flag.variadic
107+
) {
103108
syntax += ` <${flag.name}>`;
104109
} else if (flag.variadic) {
105110
syntax += ` <${flag.name}>...`;

‎packages/cli/script/generate-skill.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,12 @@ function formatFlag(flag: FlagInfo, aliases: Record<string, string>): string {
301301
if (alias) {
302302
syntax = `-${alias}, ${syntax}`;
303303
}
304-
if ((flag.kind === "parsed" || flag.kind === "enum") && !flag.variadic) {
304+
if (flag.inlineOnly) {
305+
syntax += "[=<value>]";
306+
} else if (
307+
(flag.kind === "parsed" || flag.kind === "enum") &&
308+
!flag.variadic
309+
) {
305310
syntax += " <value>";
306311
} else if (flag.variadic) {
307312
syntax += " <value>...";

‎packages/cli/src/commands/sourcemap/upload.ts‎

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import type { SentryContext } from "../../context.js";
1515
import {
1616
type ArtifactFile,
17+
DEFAULT_UPLOAD_MAX_WAIT_MS,
1718
uploadSourcemaps,
1819
} from "../../lib/api/sourcemaps.js";
1920
import { isCi } from "../../lib/ci.js";
@@ -78,6 +79,26 @@ function formatUploadResult(data: UploadCommandResult): string {
7879

7980
const 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).

‎packages/cli/src/lib/help.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,12 @@ function formatFlagHuman(
807807
if (alias) {
808808
syntax = `-${alias}, ${syntax}`;
809809
}
810-
if ((flag.kind === "parsed" || flag.kind === "enum") && !flag.variadic) {
810+
if (flag.inlineOnly) {
811+
syntax += "[=<value>]";
812+
} else if (
813+
(flag.kind === "parsed" || flag.kind === "enum") &&
814+
!flag.variadic
815+
) {
811816
syntax += " <value>";
812817
} else if (flag.variadic) {
813818
syntax += " <value>...";

‎packages/cli/src/lib/introspect.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ export type FlagDef = {
108108
variadic?: boolean;
109109
placeholder?: string;
110110
hidden?: boolean;
111+
/** Takes a value only as `--flag=value` (our Stricli patch); bare, it consumes nothing. */
112+
inlineOnly?: boolean;
111113
/** Stricli parser; completion-aware parsers carry a {@link CompletionTarget}. */
112114
parse?: unknown;
113115
/** Accepted values of an `enum` flag. */
@@ -144,6 +146,8 @@ export type FlagInfo = {
144146
optional: boolean;
145147
variadic: boolean;
146148
hidden: boolean;
149+
/** Value attaches only as `--flag=value`. */
150+
inlineOnly?: boolean;
147151
};
148152

149153
/** Extracted metadata for a route group or standalone command */
@@ -289,6 +293,7 @@ export function extractFlags(
289293
optional: def.optional ?? def.kind === "boolean",
290294
variadic: def.variadic ?? false,
291295
hidden: def.hidden ?? false,
296+
...(def.inlineOnly ? { inlineOnly: true } : {}),
292297
}));
293298
}
294299

@@ -484,7 +489,9 @@ function getCommandCompletion(command: Command): CommandCompletion {
484489
const flagKinds: Record<string, CompletionTarget | null> = {};
485490
const datasets: Record<string, DatasetCompletion> = {};
486491
for (const [name, def] of Object.entries(flags)) {
487-
if (def.kind !== "boolean") {
492+
// An inline-only flag never takes the next word, so completion treats it
493+
// like a boolean.
494+
if (def.kind !== "boolean" && !def.inlineOnly) {
488495
const { kind, values } = argumentCompletion(
489496
def.parse,
490497
def.kind === "enum" ? def.values : undefined,

0 commit comments

Comments
 (0)