Skip to content

Commit d715c2e

Browse files
fix(server): let slow provider CLIs raise their discovery probe budget (pingdotgg#6223)
Co-authored-by: Julius Marminge <[email protected]>
1 parent ad47d23 commit d715c2e

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎apps/server/src/sourceControl/AzureDevOpsSourceControlProvider.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export const discovery = {
4545
executable: "az",
4646
versionArgs: ["--version"],
4747
authArgs: ["account", "show", "--query", "user.name", "-o", "tsv"],
48+
// `az` boots a fresh Python interpreter on every invocation, so even `az --version`
49+
// takes ~6s on Windows and overruns the default budget, leaving the provider reported
50+
// as missing on machines where it is installed. `gh` and `glab` answer in ~0.3s.
51+
probeTimeoutMs: 20_000,
4852
parseAuth: parseAzureAuth,
4953
installHint:
5054
"Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",

‎apps/server/src/sourceControl/SourceControlProviderDiscovery.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type SourceControlCliDiscoverySpec = SourceControlDiscoverySpecBase & {
3333
readonly executable: string;
3434
readonly versionArgs: ReadonlyArray<string>;
3535
readonly authArgs: ReadonlyArray<string>;
36+
readonly probeTimeoutMs?: number;
3637
readonly parseAuth: (input: SourceControlAuthProbeInput) => SourceControlProviderAuth;
3738
readonly refineUnknownRemote?: (
3839
input: SourceControlUnknownRemoteRefinementInput,
@@ -52,6 +53,14 @@ type SourceControlCliRemoteRefinementSpec = SourceControlCliDiscoverySpec & {
5253
readonly refineUnknownRemote: NonNullable<SourceControlCliDiscoverySpec["refineUnknownRemote"]>;
5354
};
5455

56+
// Most provider CLIs answer `--version` in well under a second, so a short budget keeps
57+
// discovery snappy. Specs whose CLI is known to be slower can raise it via probeTimeoutMs.
58+
const DEFAULT_PROBE_TIMEOUT_MS = 5_000;
59+
60+
function probeTimeoutMs(spec: SourceControlCliDiscoverySpec): number {
61+
return spec.probeTimeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
62+
}
63+
5564
interface DiscoveryProbeResult {
5665
readonly kind: SourceControlProviderKind;
5766
readonly label: string;
@@ -167,7 +176,7 @@ function probeCli(input: {
167176
command: input.spec.executable,
168177
args: input.spec.versionArgs,
169178
cwd: input.cwd,
170-
timeoutMs: 5_000,
179+
timeoutMs: probeTimeoutMs(input.spec),
171180
maxOutputBytes: 8_000,
172181
appendTruncationMarker: true,
173182
})
@@ -244,7 +253,7 @@ export function probeSourceControlProvider(input: {
244253
args: spec.authArgs,
245254
cwd: input.cwd,
246255
allowNonZeroExit: true,
247-
timeoutMs: 5_000,
256+
timeoutMs: probeTimeoutMs(spec),
248257
maxOutputBytes: 8_000,
249258
appendTruncationMarker: true,
250259
})
@@ -287,7 +296,7 @@ export const refineUnknownRemoteProvider = Effect.fn("refineUnknownRemoteProvide
287296
args: spec.authArgs,
288297
cwd: input.cwd,
289298
allowNonZeroExit: true,
290-
timeoutMs: 5_000,
299+
timeoutMs: probeTimeoutMs(spec),
291300
maxOutputBytes: 8_000,
292301
appendTruncationMarker: true,
293302
})

0 commit comments

Comments
 (0)