Files
PaperClipAI/ui/src/lib/onboarding-connection-test.ts
T
Devin FoleyandPaperclip e3d8f42e19 fix(ui): recover stalled onboarding connection checks (#19505)
Bound the complete onboarding connection check to two minutes, abort its
requests on timeout, and ignore late results. Keep the saved account
available for retry and resume its matching unfinished setup after refresh.

Verified 242 focused tests, workspace typecheck and build, and the complete
hosted CI check set. Greptile is 5/5 with no unresolved review comments.
Local full-UI timing failure and interrupted CI runner attempts remain
documented in the PR evidence.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-06 10:31:18 -08:00

22 lines
784 B
TypeScript

export const ONBOARDING_CONNECTION_TEST_TIMEOUT_MS = 120_000;
/** Bound the entire check, including environment preparation and response parsing. */
export async function runOnboardingConnectionTest<T>(
operation: (signal: AbortSignal) => Promise<T>,
): Promise<T> {
const controller = new AbortController();
let timeout: ReturnType<typeof setTimeout> | undefined;
const deadline = new Promise<never>((_, reject) => {
timeout = setTimeout(() => {
const error = new Error("The connection test took too long. Try connecting again.");
reject(error);
controller.abort(error);
}, ONBOARDING_CONNECTION_TEST_TIMEOUT_MS);
});
try {
return await Promise.race([operation(controller.signal), deadline]);
} finally {
clearTimeout(timeout);
}
}