Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix: preserve known connection loss errors

t8y2099ed62609e5
diff --git a/apps/desktop/src/lib/connectionHealth.ts b/apps/desktop/src/lib/connectionHealth.ts
index d43f70a199..57527c7c78 100644
--- a/apps/desktop/src/lib/connectionHealth.ts
+++ b/apps/desktop/src/lib/connectionHealth.ts
@@ -7,11 +7,22 @@ const CONNECTION_ERROR_PATTERNS = [
"connection not found",
"connection config not found",
"not connected",
+ "closed the connection",
"broken pipe",
"reset by peer",
"socket closed",
"unexpected eof",
+ "end-of-file",
"end-of-file on communication channel",
+ "server closed session",
+ "communicating with the server",
+ "exceeded maximum idle time",
+ "agent stdin not available",
+ "agent stdout not available",
+ "failed to write to agent stdin",
+ "failed to flush agent stdin",
+ "关闭的连接",
+ "连接已关闭",
"i/o error",
];
diff --git a/packages/app-tests/connectionStoreErrorState.test.ts b/packages/app-tests/connectionStoreErrorState.test.ts
index 5479298ade..09ad8e5b26 100644
--- a/packages/app-tests/connectionStoreErrorState.test.ts
+++ b/packages/app-tests/connectionStoreErrorState.test.ts
@@ -102,6 +102,39 @@ test("query errors mentioning connection do not mark the connection disconnected
}
});
+test("known backend connection errors mark the connection disconnected", async () => {
+ const restoreStorage = installMemoryStorage();
+ const messages = [
+ "java.sql.SQLRecoverableException: 关闭的连接",
+ "java.sql.SQLRecoverableException: 连接已关闭",
+ "server closed session with no notification",
+ "server closed the connection unexpectedly",
+ "Error occurred while creating a new object: error communicating with the server",
+ "ORA-02396: exceeded maximum idle time, please connect again",
+ "Agent stdin not available",
+ "Failed to write to agent stdin",
+ ];
+
+ try {
+ for (const [index, message] of messages.entries()) {
+ setActivePinia(createPinia());
+ const store = useConnectionStore();
+ const connectionId = `conn-${index}`;
+ store.addEphemeralConnection(conn(connectionId));
+ store.activeConnectionId = connectionId;
+
+ const marked = store.recordConnectionLostError(connectionId, new Error(message));
+
+ assert.equal(marked, true, message);
+ assert.equal(store.connectedIds.has(connectionId), false, message);
+ assert.equal(store.activeConnectionId, null, message);
+ }
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ } finally {
+ restoreStorage();
+ }
+});
+
test("explicit lost-connection marker clears state without relying on error text", async () => {
const restoreStorage = installMemoryStorage();
try {