mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
Behavior-preserving refactor. Eleven sites built the same `signal ? AbortSignal.any([signal, AbortSignal.timeout(ms)]) : AbortSignal.timeout(ms)` inline or behind a local wrapper (Codex `createCodexBackendRequestSignal`, `probeDeadline`, `boundedSignal`). They now call one `abortSignalWithTimeout(signal, timeoutMs)` in src/main/lib/abort-signal-with-timeout.ts: - usage requests: Claude OAuth, Cursor, Grok, OpenCode Go API key, ZCode, Codex backend usage + reset-credit read - local worktree path presence, fork sync, retarget divergence budget, upstream-ref watch resolution The Codex reset-credit redeem, which never had a caller signal, uses plain AbortSignal.timeout. Transports, request options, timeout values, error mapping, and Retry-After handling are unchanged.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { normalizeGitErrorMessage } from '../../shared/git-remote-error'
|
|
import {
|
|
syncForkDefaultBranch,
|
|
type GitForkSyncExpectedUpstream,
|
|
type GitForkSyncResult
|
|
} from '../../shared/git-fork-sync'
|
|
import type { GitRuntimeOptions } from './git-runtime-options'
|
|
import { gitOptionsForWorktree } from './git-runtime-options'
|
|
import { gitExecFileAsync } from './runner'
|
|
import { abortSignalWithTimeout } from '../lib/abort-signal-with-timeout'
|
|
|
|
export async function gitSyncForkDefaultBranch(
|
|
worktreePath: string,
|
|
expectedUpstream: GitForkSyncExpectedUpstream,
|
|
options: GitRuntimeOptions = {}
|
|
): Promise<GitForkSyncResult> {
|
|
// Compose the caller's cancel signal with the 60s timeout so neither is lost —
|
|
// the caller's signal was previously clobbered by the timeout controller.
|
|
const signal = abortSignalWithTimeout(options.signal, 60_000)
|
|
try {
|
|
return await syncForkDefaultBranch(
|
|
(args) =>
|
|
gitExecFileAsync(args, {
|
|
...gitOptionsForWorktree(worktreePath, options),
|
|
timeout: 60_000,
|
|
signal
|
|
}),
|
|
{ expectedUpstream }
|
|
)
|
|
} catch (error) {
|
|
throw new Error(normalizeGitErrorMessage(error, 'push'))
|
|
}
|
|
}
|