actualbudget/actual · critical · Error
Failed to init the server bundle after all retries: ${String
Error message
Failed to init the server bundle after all retries: ${String(error)} What it means
After retrying up to 30 times, `lazyLoadBackend` failed to import or `initApp` the loot-core server bundle. The original error is logged to console.error and rewrapped in this generic error so the Electron main process can surface a single message.
Source
Thrown at packages/desktop-electron/server.ts:37
} catch (error) {
console.info(
`Loading server bundle: Attempt ${number} of ${BACKEND_IMPORT_MAX_RETRIES}`,
);
retry(error);
}
},
{
retries: BACKEND_IMPORT_MAX_RETRIES,
minTimeout: 1000,
maxTimeout: 1000,
factor: 1, // No exponential backoff
},
);
bundle.initApp(isDev);
} catch (error) {
console.error('Failed to init the server bundle after all retries:', error);
throw new Error(
`Failed to init the server bundle after all retries: ${String(error)}`,
);
}
};
const isDev = false;
// Start the app
void lazyLoadBackend(isDev);
View on GitHub (pinned to d4334cb6e6)
Solutions
- Read the original error printed by `console.error('Failed to init the server bundle after all retries:', error)` — it names the root cause
- Rebuild loot-core (`yarn workspace @actual-app/core build`) and relaunch so a fresh valid bundle exists
- Verify ACTUAL_DATA_DIR is set and writable, since initApp failures inside the bundle surface here
- Delete stale build artifacts (lib-dist) and rebuild from clean
Defensive patterns
Strategy: try-catch
Validate before calling
// before launching: verify bundle and data dir
import fs from 'fs';
if (!fs.existsSync(process.env.lootCoreScript!)) throw new Error('server bundle missing');
if (!process.env.ACTUAL_DATA_DIR || !fs.existsSync(process.env.ACTUAL_DATA_DIR)) throw new Error('ACTUAL_DATA_DIR invalid'); Try / catch
try {
await lazyLoadBackend(isDev);
} catch (e) {
console.error('Backend init failed:', e);
// inspect the ORIGINAL error logged by lazyLoadBackend for the root cause
process.exit(1);
} Prevention
- Rebuild loot-core after pulling changes so the bundle is fresh
- Clear stale lib-dist artifacts when init keeps failing
- Ensure ACTUAL_DATA_DIR is set and writable before initApp runs
When it happens
Trigger: The dynamic `import()` of `lootCoreScript` keeps failing (missing/corrupt bundle, wrong path, syntax error) or `bundle.initApp(isDev)` throws (e.g. bad ACTUAL_DATA_DIR, DB init failure) across all retries with factor 1 (no backoff).
Common situations: Incomplete `yarn build` leaving an outdated or missing lib-dist bundle; a crash in initApp due to unwritable data dir; dev watchers not yet emitting the bundle when packaged mode starts.
Related errors
- The environment variable `lootCoreScript` is not defined. Pl
- applyAppUpdate not implemented in electron app
- ACTUAL_DATA_DIR is not set
- ACTUAL_DATA_DIR env variable is required
- Invalid token_expiration value: ${val}: value was "${val}"
AI-assisted analysis of actualbudget/actual@d4334cb6e6 (2026-08-29).
Data as JSON: /api/errors/61b14e7ee74036ee.
Report an issue: GitHub.