fix: preserve known connection loss errors
This commit is contained in:
parent
718ffde871
commit
099ed62609
|
|
@ -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",
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue