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: show timeout action for SQL execution timeouts

zipg52835f1eb0b3
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue
index 94de3623ae..658cb63c1f 100644
--- a/apps/desktop/src/components/layout/ContentArea.vue
+++ b/apps/desktop/src/components/layout/ContentArea.vue
@@ -54,6 +54,7 @@ import { useConnectionStore } from "@/stores/connectionStore";
import { TABLE_FONT_SIZE_MAX, TABLE_FONT_SIZE_MIN, useSettingsStore, type DataGridSearchMode } from "@/stores/settingsStore";
import { useToast } from "@/composables/useToast";
import { canCancelQueryExecution, queryExecutionLabelKey } from "@/lib/sql/queryExecutionState";
+import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
import { databaseDisplayNameForTab, executionSummaryItems, nextExecutionSummaryView, resultGridCacheKey, resultRunItems, resultSqlForGrid, tabularResultItems } from "@/lib/tabs/tabPresentation";
import { defaultQueryResultArchiveFileName } from "@/lib/query/queryResultArchive";
import { saveQueryResultArchiveFile } from "@/lib/query/queryResultArchiveFile";
@@ -185,10 +186,6 @@ const dataGridSearchMode = computed(() => settingsStore.editorSettings.dataGridS
const tableFontSize = computed(() => settingsStore.editorSettings.tableFontSize);
const redisKeyBrowserRef = ref<SearchableBrowserHandle>();
-function isQueryTimeoutError(message: string): boolean {
- const lower = message.toLowerCase();
- return lower.includes("query timed out") || lower.includes("查询超时");
-}
const etcdKeyBrowserRef = ref<SearchableBrowserHandle>();
const zookeeperKeyBrowserRef = ref<SearchableBrowserHandle>();
const objectBrowserRef = ref<SearchableBrowserHandle>();
@@ -1116,7 +1113,7 @@ defineExpose({ focusSearch, refreshData, handleModRTarget, requestQueryEditorExe
@sort="(column: string, columnIndex: number, direction: 'asc' | 'desc' | null, whereInput?: string, mode?: DataGridSortMode) => emit('sort', column, columnIndex, direction, whereInput, mode)"
>
<template v-if="activeTab.result?.columns.includes('Error')" #error-actions="{ errorMessage }">
- <Button v-if="activeTab.connectionId && isQueryTimeoutError(String(errorMessage))" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('openConnectionSettings', activeTab.connectionId, 'advanced')">
+ <Button v-if="activeTab.connectionId && isQueryTimeoutErrorMessage(String(errorMessage))" variant="outline" size="sm" class="h-7 gap-1.5 px-2.5 text-xs" @click="emit('openConnectionSettings', activeTab.connectionId, 'advanced')">
<Wrench class="h-3.5 w-3.5" />
{{ t("editor.changeQueryTimeout") }}
</Button>
diff --git a/apps/desktop/src/lib/__tests__/sql/queryError.spec.ts b/apps/desktop/src/lib/__tests__/sql/queryError.spec.ts
new file mode 100644
index 0000000000..de7d24eb47
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/sql/queryError.spec.ts
@@ -0,0 +1,38 @@
+import { describe, expect, it } from "vitest";
+import { isQueryTimeoutErrorMessage } from "@/lib/sql/queryError";
+
+describe("isQueryTimeoutErrorMessage", () => {
+ it("detects DBX query timeout messages", () => {
+ expect(isQueryTimeoutErrorMessage("Query timed out after 30 seconds")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("查询超时 (60s),请检查数据库连接是否正常")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("查詢逾時 (60s),請檢查資料庫連線是否正常")).toBe(true);
+ });
+
+ it("detects statement timeout messages", () => {
+ expect(isQueryTimeoutErrorMessage("ERROR: canceling statement due to statement timeout")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("ERROR: cancelling statement due to statement timeout")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("Statement timed out after 10 seconds")).toBe(true);
+ });
+
+ it("detects generic query execution timeout messages", () => {
+ expect(isQueryTimeoutErrorMessage("SQL execution timed out after 30s")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("Execution Timeout Expired. The timeout period elapsed prior to completion of the operation.")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("Query exceeded maximum execution time")).toBe(true);
+ });
+
+ it("detects agent RPC client-side timeout", () => {
+ expect(isQueryTimeoutErrorMessage("Agent RPC call timed out (30s)")).toBe(true);
+ expect(isQueryTimeoutErrorMessage("Agent RPC call timed out (120s)")).toBe(true);
+ });
+
+ it("does not classify unrelated errors as query timeouts", () => {
+ expect(isQueryTimeoutErrorMessage('syntax error at or near "select"')).toBe(false);
+ expect(isQueryTimeoutErrorMessage("Connection timed out while loading databases")).toBe(false);
+ expect(isQueryTimeoutErrorMessage("PostgreSQL connection pool checkout timed out (5s)")).toBe(false);
+ expect(isQueryTimeoutErrorMessage("Cancel request timed out after 10s.")).toBe(false);
+ expect(isQueryTimeoutErrorMessage("HTTP tunnel script read timed out")).toBe(false);
+ expect(isQueryTimeoutErrorMessage('invalid value for parameter "statement_timeout"')).toBe(false);
+ // Agent RPC errors that are not timeouts must not trigger the action.
+ expect(isQueryTimeoutErrorMessage('Agent RPC error (-1): syntax error at or near "select"')).toBe(false);
+ });
+});
diff --git a/apps/desktop/src/lib/sql/queryError.ts b/apps/desktop/src/lib/sql/queryError.ts
new file mode 100644
index 0000000000..6ceb0f2558
--- /dev/null
+++ b/apps/desktop/src/lib/sql/queryError.ts
@@ -0,0 +1,16 @@
+export function isQueryTimeoutErrorMessage(message: string): boolean {
+ const lower = message.toLowerCase();
+ if (lower.includes("query timed out") || lower.includes("查询超时") || lower.includes("查詢逾時")) return true;
+ // Agent RPC client-side timeout (tokio::time::timeout in agent_driver.rs). This is the
+ // fallback when JDBC setQueryTimeout never fires (unsupported/unresponsive driver), so the
+ // backend already treats it as a query timeout (is_agent_rpc_timeout_error in query.rs) —
+ // surface the same action here to stay consistent with the backend.
+ if (lower.startsWith("agent rpc call timed out")) return true;
+ if (/\b(?:canceling|cancelling|canceled|cancelled)\b[\s\S]{0,80}\bstatement\b[\s\S]{0,80}\btimeout\b/.test(lower)) return true;
+ if (/\b(?:connection|connect|pool|checkout|metadata|loading|health check|cancel request|ssh|tunnel)\b/.test(lower)) return false;
+ return (
+ /\b(?:query|statement|sql|execution|execute|executing)\b[\s\S]{0,80}\b(?:timed out|timeout expired|timeout exceeded|time-out)\b/.test(lower) ||
+ /\b(?:timed out|timeout expired|timeout exceeded|time-out)\b[\s\S]{0,80}\b(?:query|statement|sql|execution|execute|executing)\b/.test(lower) ||
+ /\bquery\b[\s\S]{0,80}\bexceeded\b[\s\S]{0,80}\b(?:execution\s+)?time\b/.test(lower)
+ );
+}