mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
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>
22 lines
784 B
TypeScript
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);
|
|
}
|
|
}
|