Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(onboarding): increase pipe install reliability with retries and longer timeout

Louis Beaumont57641419a3fd
diff --git a/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx b/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx
index 64ef82197..b834451e5 100644
--- a/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx
+++ b/apps/screenpipe-app-tauri/components/onboarding/pick-pipe.tsx
@@ -51,44 +51,55 @@ const PATHS = [
type PathId = (typeof PATHS)[number]["id"];
type Phase = "choose" | "enabling" | "done";
-async function waitForServer(maxWaitMs = 10000): Promise<void> {
+async function waitForServer(maxWaitMs = 30000): Promise<void> {
const start = Date.now();
while (Date.now() - start < maxWaitMs) {
try {
const res = await localFetch("/health");
if (res.ok) return;
} catch {}
- await new Promise((r) => setTimeout(r, 500));
+ await new Promise((r) => setTimeout(r, 1000));
}
throw new Error("server not ready");
}
-async function installAndEnable(slug: string): Promise<void> {
- // Wait for server to be ready before attempting install
+async function installAndEnable(slug: string, retries = 3): Promise<void> {
await waitForServer();
- const enableRes = await localFetch(
- `/pipes/${slug}/enable`,
- {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ enabled: true }),
- }
- );
+ for (let attempt = 1; attempt <= retries; attempt++) {
+ try {
+ // Try enabling first (pipe might already be installed)
+ const enableRes = await localFetch(`/pipes/${slug}/enable`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ enabled: true }),
+ });
+ if (enableRes.ok) return;
- if (!enableRes.ok) {
- const installRes = await localFetch("/pipes/store/install", {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ slug }),
- });
- if (!installRes.ok) throw new Error(`failed to install ${slug}`);
+ // Not installed — install from store
+ const installRes = await localFetch("/pipes/store/install", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ slug }),
+ });
+ if (!installRes.ok) {
+ const text = await installRes.text().catch(() => "");
+ throw new Error(`install ${slug}: ${installRes.status} ${text}`);
+ }
- await localFetch(`/pipes/${slug}/enable`, {
- method: "POST",
- headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ enabled: true }),
- });
+ // Enable after install
+ const enable2 = await localFetch(`/pipes/${slug}/enable`, {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ enabled: true }),
+ });
+ if (enable2.ok) return;
+ throw new Error(`enable ${slug} after install: ${enable2.status}`);
+ } catch (err) {
+ if (attempt === retries) throw err;
+ console.warn(`pipe ${slug} attempt ${attempt}/${retries} failed, retrying...`, err);
+ await new Promise((r) => setTimeout(r, 2000 * attempt));
+ }
}
}