Repository navigation
Fix: seed reliability — retry IPC failures, verify Rust worker ready - #610
Conversation
…ore seeding Seed was failing on fresh installs because Rust IPC wasn't ready when seeding started. Two fixes: 1. waitForJTAGReady() now verifies Rust IPC via data/list before proceeding 2. createUserViaCommand() retries 3x with backoff on IPC/timeout errors
There was a problem hiding this comment.
Pull request overview
Improves data:seed reliability on fresh installs by gating seeding on Rust IPC readiness and adding retries for transient IPC/timeout failures during user creation.
Changes:
- Add retry-with-backoff to
createUserViaCommand()when user creation fails due to transient IPC/timeout conditions. - Extend
waitForJTAGReady()to additionally verify Rust IPC connectivity by running adata/listcommand before proceeding.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/scripts/seed/helpers.ts |
Adds retry/backoff logic (and exec timeout) around ./jtag user/create to reduce flakiness during early startup. |
src/scripts/seed-continuum.ts |
Updates readiness gating to wait for Rust IPC by probing data/list after ping reports TS server readiness. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // IPC/timeout errors — retry if attempts remain | ||
| const isTransient = err.message?.includes('IPC') || err.message?.includes('timeout') || err.message?.includes('TIMEOUT'); | ||
| if (isTransient && attempt < MAX_RETRIES) { | ||
| console.log(` ⏳ Transient error, retrying in ${attempt * 3}s (attempt ${attempt}/${MAX_RETRIES})...`); | ||
| await new Promise(r => setTimeout(r, attempt * 3000)); | ||
| continue; |
There was a problem hiding this comment.
The retry logic treats timeouts as transient by checking substrings in err.message, but child_process.exec timeout errors often don't include "timeout"/"TIMEOUT" in the message (they may surface via killed, signal, or code like ETIMEDOUT). This can prevent retries from happening on actual timeouts. Consider detecting timeouts via the exec error fields (e.g., (err as any).killed, (err as any).signal, (err as any).code) and including that in isTransient.
| const { stdout: dbCheck } = await execAsync('./jtag data/list --collection=users --limit=1', { timeout: 10000 }); | ||
| if (dbCheck.includes('"success":true') || dbCheck.includes('"success": true')) { |
There was a problem hiding this comment.
The Rust IPC readiness check looks for string snippets in data/list output. Since ./jtag commands can emit extra log lines (you already robustly extract JSON for ping above), this can be brittle and can mis-detect readiness. Consider extracting/parsing the JSON from dbCheck and checking result.success === true (and optionally use DATA_COMMANDS.LIST instead of a hard-coded data/list string for consistency).
| const { stdout: dbCheck } = await execAsync('./jtag data/list --collection=users --limit=1', { timeout: 10000 }); | |
| if (dbCheck.includes('"success":true') || dbCheck.includes('"success": true')) { | |
| const { stdout: dbCheck } = await execAsync(`./jtag ${DATA_COMMANDS.LIST} --collection=users --limit=1`, { timeout: 10000 }); | |
| // Extract JSON from potentially polluted data/list output | |
| const firstDbBrace = dbCheck.indexOf('{'); | |
| const lastDbBrace = dbCheck.lastIndexOf('}'); | |
| if (firstDbBrace === -1 || lastDbBrace === -1 || firstDbBrace > lastDbBrace) { | |
| throw new Error('No valid JSON in data/list output'); | |
| } | |
| const dbJsonStr = dbCheck.substring(firstDbBrace, lastDbBrace + 1); | |
| const dbResponse = JSON.parse(dbJsonStr); | |
| if (dbResponse?.result?.success === true) { |
Problem
Seeding fails on fresh installs:
All IPC connections to continuum-core failed. The Rust worker isn't ready when seeding starts.Fix
waitForJTAGReady()now verifies Rust IPC viadata/list— won't proceed until Rust worker respondscreateUserViaCommand()retries 3x with backoff on IPC/timeout errorsTest
npm run data:seedsucceeds — all 16 personas created