fix(app): retry connection list loading at startup

This commit is contained in:
Jinpy authored and GitHub committed 2026-10-04 09:47:39 +08:00
1 parent fbd50acf00
commit 397bff26c8
1 file changed
+16 -1
+16 -1
View File
@@ -4071,7 +4071,22 @@ async function initApp() {
await settingsStore.initEditorSettings(); await settingsStore.initEditorSettings();
markStartupPhase("settings-ready"); markStartupPhase("settings-ready");
console.log(`[STARTUP] settingsStore.initEditorSettings: ${(performance.now() - t0).toFixed(0)}ms`); console.log(`[STARTUP] settingsStore.initEditorSettings: ${(performance.now() - t0).toFixed(0)}ms`);
await connectionStore.initFromDisk(); // 连接列表加载是启动链路的单点:这里的一次瞬态失败(web/docker 下偶发,
// 如认证握手期间的一次请求失败)会被外层 catch 收成一个一闪而过的 toast,
// 应用随后以空连接列表运行,除整页 reload 外没有任何恢复入口。有界重试
// 吸收瞬态失败;重试耗尽才交给外层 toast(认证类失败重试也无济于事,
// 行为不劣于现状)。
const connectionLoadAttempts = 3;
for (let attempt = 1; ; attempt += 1) {
try {
await connectionStore.initFromDisk();
break;
} catch (error) {
if (attempt >= connectionLoadAttempts) throw error;
console.warn(`[STARTUP] connectionStore.initFromDisk failed (attempt ${attempt}/${connectionLoadAttempts}), retrying`, error);
await new Promise((resolve) => setTimeout(resolve, 300 * attempt));
}
}
markStartupPhase("connections-ready"); markStartupPhase("connections-ready");
console.log(`[STARTUP] connectionStore.initFromDisk: ${(performance.now() - t0).toFixed(0)}ms`); console.log(`[STARTUP] connectionStore.initFromDisk: ${(performance.now() - t0).toFixed(0)}ms`);
await queryStore.initOpenTabs({ validConnectionIds: connectionStore.connections.map((connection) => connection.id) }); await queryStore.initOpenTabs({ validConnectionIds: connectionStore.connections.map((connection) => connection.id) });