Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const discovery = {
executable: "az",
versionArgs: ["--version"],
authArgs: ["account", "show", "--query", "user.name", "-o", "tsv"],
// `az` boots a fresh Python interpreter on every invocation, so even `az --version`
// takes ~6s on Windows and overruns the default budget, leaving the provider reported
// as missing on machines where it is installed. `gh` and `glab` answer in ~0.3s.
probeTimeoutMs: 20_000,
parseAuth: parseAzureAuth,
installHint:
"Install the Azure command-line tools (`az`), then enable Azure DevOps support with `az extension add --name azure-devops`.",
Expand Down
15 changes: 12 additions & 3 deletions apps/server/src/sourceControl/SourceControlProviderDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type SourceControlCliDiscoverySpec = SourceControlDiscoverySpecBase & {
readonly executable: string;
readonly versionArgs: ReadonlyArray<string>;
readonly authArgs: ReadonlyArray<string>;
readonly probeTimeoutMs?: number;
readonly parseAuth: (input: SourceControlAuthProbeInput) => SourceControlProviderAuth;
readonly refineUnknownRemote?: (
input: SourceControlUnknownRemoteRefinementInput,
Expand All @@ -52,6 +53,14 @@ type SourceControlCliRemoteRefinementSpec = SourceControlCliDiscoverySpec & {
readonly refineUnknownRemote: NonNullable<SourceControlCliDiscoverySpec["refineUnknownRemote"]>;
};

// Most provider CLIs answer `--version` in well under a second, so a short budget keeps
// discovery snappy. Specs whose CLI is known to be slower can raise it via probeTimeoutMs.
const DEFAULT_PROBE_TIMEOUT_MS = 5_000;

function probeTimeoutMs(spec: SourceControlCliDiscoverySpec): number {
return spec.probeTimeoutMs ?? DEFAULT_PROBE_TIMEOUT_MS;
}

interface DiscoveryProbeResult {
readonly kind: SourceControlProviderKind;
readonly label: string;
Expand Down Expand Up @@ -167,7 +176,7 @@ function probeCli(input: {
command: input.spec.executable,
args: input.spec.versionArgs,
cwd: input.cwd,
timeoutMs: 5_000,
timeoutMs: probeTimeoutMs(input.spec),
maxOutputBytes: 8_000,
appendTruncationMarker: true,
})
Expand Down Expand Up @@ -244,7 +253,7 @@ export function probeSourceControlProvider(input: {
args: spec.authArgs,
cwd: input.cwd,
allowNonZeroExit: true,
timeoutMs: 5_000,
timeoutMs: probeTimeoutMs(spec),
maxOutputBytes: 8_000,
appendTruncationMarker: true,
})
Expand Down Expand Up @@ -287,7 +296,7 @@ export const refineUnknownRemoteProvider = Effect.fn("refineUnknownRemoteProvide
args: spec.authArgs,
cwd: input.cwd,
allowNonZeroExit: true,
timeoutMs: 5_000,
timeoutMs: probeTimeoutMs(spec),
maxOutputBytes: 8_000,
appendTruncationMarker: true,
})
Expand Down
Loading