{"record":{"id":"61b14e7ee74036ee","repo":"actualbudget/actual","slug":"failed-to-init-the-server-bundle-after-all-retries","errorCode":null,"errorMessage":"Failed to init the server bundle after all retries: ${String(error)}","messagePattern":"Failed to init the server bundle after all retries: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/desktop-electron/server.ts","lineNumber":37,"sourceCode":"        } catch (error) {\n          console.info(\n            `Loading server bundle: Attempt ${number} of ${BACKEND_IMPORT_MAX_RETRIES}`,\n          );\n\n          retry(error);\n        }\n      },\n      {\n        retries: BACKEND_IMPORT_MAX_RETRIES,\n        minTimeout: 1000,\n        maxTimeout: 1000,\n        factor: 1, // No exponential backoff\n      },\n    );\n    bundle.initApp(isDev);\n  } catch (error) {\n    console.error('Failed to init the server bundle after all retries:', error);\n    throw new Error(\n      `Failed to init the server bundle after all retries: ${String(error)}`,\n    );\n  }\n};\n\nconst isDev = false;\n\n// Start the app\nvoid lazyLoadBackend(isDev);\n","sourceCodeStart":19,"sourceCodeEnd":47,"githubUrl":"https://github.com/actualbudget/actual/blob/d4334cb6e6123f4d3bcea1ad6166608884c7e658/packages/desktop-electron/server.ts#L19-L47","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before launching: verify bundle and data dir\nimport fs from 'fs';\nif (!fs.existsSync(process.env.lootCoreScript!)) throw new Error('server bundle missing');\nif (!process.env.ACTUAL_DATA_DIR || !fs.existsSync(process.env.ACTUAL_DATA_DIR)) throw new Error('ACTUAL_DATA_DIR invalid');","typeGuard":null,"tryCatchPattern":"try {\n  await lazyLoadBackend(isDev);\n} catch (e) {\n  console.error('Backend init failed:', e);\n  // inspect the ORIGINAL error logged by lazyLoadBackend for the root cause\n  process.exit(1);\n}","preventionTips":["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"],"tags":["electron","startup","init-failure","retry-exhausted"],"backgroundTag":"backend-init-failed","analyzedSha":"d4334cb6e6123f4d3bcea1ad6166608884c7e658","analyzedAt":"2026-08-29T01:02:11.213Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}