feat: make query timeout configurable via global settings (default 30s)
Add queryTimeoutSecs to editor settings with UI control in the settings dialog. 0 means no timeout. Applied to all query execution paths including sidebar table data loading and EXPLAIN queries. Closes #441.
This commit is contained in:
1 parent
db00051632
commit
792c816a17
10 files changed
+127
-18
No files matched your search
@@ -643,18 +643,20 @@ export const useQueryStore = defineStore("query", () => {
|
||||
}
|
||||
|
||||
console.info("[DBX][executeTabSql:execute-multi:start]", { traceId, elapsed: elapsed() });
|
||||
const executionOptions =
|
||||
typeof pageLimit === "number"
|
||||
const executionOptions = {
|
||||
...(typeof pageLimit === "number"
|
||||
? useAgentResultSession
|
||||
? {
|
||||
maxRows: pageLimit,
|
||||
fetchSize: pageLimit,
|
||||
pageSize: pageLimit,
|
||||
resultSessionId: options?.pagination?.sessionId,
|
||||
clientSessionId: tab.id,
|
||||
}
|
||||
: { maxRows: pageLimit, fetchSize: pageLimit, clientSessionId: tab.id }
|
||||
: undefined;
|
||||
: { maxRows: pageLimit, fetchSize: pageLimit }
|
||||
: {}),
|
||||
clientSessionId: tab.id,
|
||||
timeoutSecs: settingsStore.editorSettings.queryTimeoutSecs,
|
||||
};
|
||||
const results = await api.executeMulti(
|
||||
tab.connectionId,
|
||||
tab.database,
|
||||
@@ -755,6 +757,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
try {
|
||||
const result = await api.executeQuery(tab.connectionId, tab.database, built.sql, tab.schema, executionId, {
|
||||
clientSessionId: tab.id,
|
||||
timeoutSecs: useSettingsStore().editorSettings.queryTimeoutSecs,
|
||||
});
|
||||
const current = tabs.value.find((t) => t.id === id);
|
||||
if (current?.explainExecutionId === executionId) {
|
||||
|
||||
@@ -187,6 +187,8 @@ export interface EditorSettings {
|
||||
columnFormatters: Record<string, ColumnFormatterConfig>;
|
||||
customColumnFormatters: Record<string, CustomColumnFormatterConfig>;
|
||||
snippets: SqlSnippet[];
|
||||
/** Query timeout in seconds. 0 = no timeout. Default 30s. */
|
||||
queryTimeoutSecs: number;
|
||||
}
|
||||
|
||||
export const EDITOR_THEMES: { value: EditorTheme; label: string; dark: boolean }[] = [
|
||||
@@ -232,6 +234,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
||||
columnFormatters: {},
|
||||
customColumnFormatters: {},
|
||||
snippets: DEFAULT_SQL_SNIPPETS,
|
||||
queryTimeoutSecs: 30,
|
||||
};
|
||||
|
||||
export const STORAGE_KEY = "dbx-editor-settings";
|
||||
@@ -283,6 +286,11 @@ function normalizeSqlSnippets(value: unknown, existing?: SqlSnippet[]): SqlSnipp
|
||||
return valid;
|
||||
}
|
||||
|
||||
function normalizeQueryTimeoutSecs(value: unknown): number {
|
||||
if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
|
||||
return DEFAULT_EDITOR_SETTINGS.queryTimeoutSecs;
|
||||
}
|
||||
|
||||
export function normalizeEditorSettings(settings: Partial<EditorSettings>, existing?: EditorSettings): EditorSettings {
|
||||
return {
|
||||
fontFamily: settings.fontFamily ?? DEFAULT_EDITOR_SETTINGS.fontFamily,
|
||||
@@ -306,6 +314,7 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
||||
columnFormatters: normalizeColumnFormatters(settings.columnFormatters),
|
||||
customColumnFormatters: normalizeCustomColumnFormatters(settings.customColumnFormatters),
|
||||
snippets: normalizeSqlSnippets(settings.snippets, existing?.snippets),
|
||||
queryTimeoutSecs: normalizeQueryTimeoutSecs(settings.queryTimeoutSecs),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -408,6 +417,9 @@ export const useSettingsStore = defineStore("settings", () => {
|
||||
const normalizedPartial = {
|
||||
...partial,
|
||||
...(partial.pageSize !== undefined ? { pageSize: normalizeResultPageSize(partial.pageSize) } : {}),
|
||||
...(partial.queryTimeoutSecs !== undefined
|
||||
? { queryTimeoutSecs: normalizeQueryTimeoutSecs(partial.queryTimeoutSecs) }
|
||||
: {}),
|
||||
...(partial.sidebarHiddenTablePrefixes !== undefined
|
||||
? { sidebarHiddenTablePrefixes: normalizeSidebarHiddenTablePrefixes(partial.sidebarHiddenTablePrefixes) }
|
||||
: {}),
|
||||
|
||||
Reference in new issue
Block a user