f3f6ba47fe
Resolves all merge conflicts, preserving our split module structure while integrating all dev changes: - Custom agent summaries support (parseRegisteredAgentSummaries) - Background notification queue (enqueueNotificationForParent) - Atlas shared git-worktree module (collectGitDiffStats, formatFileChanges) - Ralph-loop withTimeout + DEFAULT_API_TIMEOUT=5000 - Session recovery assistant_prefill_unsupported error type - Atlas agentOverrides forwarding - Config handler plan model demotion (buildPlanDemoteConfig) - Delegate-task agentOverrides, promptSyncWithModelSuggestionRetry, variant - LSP init timeout + stale init detection - isPlanFamily function + task-continuation-enforcer hook - Handoff command
21 lines
461 B
TypeScript
21 lines
461 B
TypeScript
export async function withTimeout<TData>(
|
|
promise: Promise<TData>,
|
|
timeoutMs: number,
|
|
): Promise<TData> {
|
|
let timeoutId: ReturnType<typeof setTimeout> | undefined
|
|
|
|
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
timeoutId = setTimeout(() => {
|
|
reject(new Error("API timeout"))
|
|
}, timeoutMs)
|
|
})
|
|
|
|
try {
|
|
return await Promise.race([promise, timeoutPromise])
|
|
} finally {
|
|
if (timeoutId !== undefined) {
|
|
clearTimeout(timeoutId)
|
|
}
|
|
}
|
|
}
|