fix(connection): clear warnings after metadata recovery
This commit is contained in:
10 files changed
+226
-9
No files matched your search
@@ -352,6 +352,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
const cancelledLocalConnectionAttempts = new Map<string, Set<number>>();
|
||||
const successfulLocalConnectionAttempts = new Map<string, number>();
|
||||
const connectionStateRevisions = new Map<string, number>();
|
||||
const connectionErrorRevisions = new Map<string, number>();
|
||||
let nextLocalConnectionAttempt = 0;
|
||||
let beforeConnectHandler: BeforeConnectHandler | null = null;
|
||||
let initFromDiskPromise: Promise<void> | null = null;
|
||||
@@ -375,7 +376,9 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
}
|
||||
|
||||
logMetadataLoadTrace(metadataTraceLogger, trace, "cache-miss", { cacheStatus: options?.force ? "refresh" : "miss", force: options?.force === true });
|
||||
const errorRevision = connectionErrorRevision(scope.connectionId);
|
||||
const result = await load();
|
||||
clearConnectionErrorIfUnchanged(scope.connectionId, errorRevision);
|
||||
metadataListPageCache.set(scope, result);
|
||||
logMetadataLoadTrace(metadataTraceLogger, trace, "done", {
|
||||
cacheStatus: options?.force ? "refresh" : "miss",
|
||||
@@ -610,6 +613,22 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
|
||||
function setConnectionError(connectionId: string, message: string) {
|
||||
connectionErrors.value[connectionId] = message;
|
||||
connectionErrorRevisions.set(connectionId, connectionErrorRevision(connectionId) + 1);
|
||||
}
|
||||
|
||||
function updateConnectionErrorPresentation(connectionId: string, expectedMessage: string, message: string) {
|
||||
// Hints decorate the current error event and must not invalidate a retry's recovery revision.
|
||||
if (connectionErrors.value[connectionId] !== expectedMessage) return;
|
||||
connectionErrors.value[connectionId] = message;
|
||||
}
|
||||
|
||||
function connectionErrorRevision(connectionId?: string | null): number {
|
||||
return connectionId ? (connectionErrorRevisions.get(connectionId) ?? 0) : 0;
|
||||
}
|
||||
|
||||
function clearConnectionErrorIfUnchanged(connectionId: string | null | undefined, revision: number) {
|
||||
if (!connectionId || connectionErrorRevision(connectionId) !== revision) return;
|
||||
clearConnectionError(connectionId);
|
||||
}
|
||||
|
||||
function agentDriverUpdateHint(): string {
|
||||
@@ -641,19 +660,20 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
const config = getConfig(connectionId);
|
||||
const message = connectionErrorWithDriverUpdateHint(config, baseMessage);
|
||||
if (message !== baseMessage) {
|
||||
setConnectionError(connectionId, message);
|
||||
updateConnectionErrorPresentation(connectionId, baseMessage, message);
|
||||
return;
|
||||
}
|
||||
void refreshAgentDriversForErrorHint().then(() => {
|
||||
if (connectionErrors.value[connectionId] !== baseMessage) return;
|
||||
const refreshedMessage = connectionErrorWithDriverUpdateHint(config, baseMessage);
|
||||
if (refreshedMessage !== baseMessage) setConnectionError(connectionId, refreshedMessage);
|
||||
if (refreshedMessage !== baseMessage) updateConnectionErrorPresentation(connectionId, baseMessage, refreshedMessage);
|
||||
});
|
||||
}
|
||||
|
||||
function clearConnectionError(connectionId: string) {
|
||||
if (!connectionErrors.value[connectionId]) return;
|
||||
delete connectionErrors.value[connectionId];
|
||||
connectionErrorRevisions.set(connectionId, connectionErrorRevision(connectionId) + 1);
|
||||
}
|
||||
|
||||
function markConnectionHealthChecked(connectionId: string) {
|
||||
@@ -703,9 +723,10 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
|
||||
async function withMetadataLoadTimeout<T>(connectionId: string, promise: Promise<T>, label: string): Promise<T> {
|
||||
const timeoutMs = metadataLoadTimeoutMs(getConfig(connectionId));
|
||||
const errorRevision = connectionErrorRevision(connectionId);
|
||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||
try {
|
||||
return await Promise.race([
|
||||
const result = await Promise.race([
|
||||
promise,
|
||||
new Promise<never>((_, reject) => {
|
||||
timer = setTimeout(() => {
|
||||
@@ -713,6 +734,8 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
}, timeoutMs);
|
||||
}),
|
||||
]);
|
||||
clearConnectionErrorIfUnchanged(connectionId, errorRevision);
|
||||
return result;
|
||||
} finally {
|
||||
if (timer) clearTimeout(timer);
|
||||
}
|
||||
@@ -1753,6 +1776,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
persistPinnedTreeNodeIds();
|
||||
for (const id of removedIds) {
|
||||
clearConnectionError(id);
|
||||
connectionErrorRevisions.delete(id);
|
||||
connectedIds.value.delete(id);
|
||||
clearConnectionIdentifierQuote(id);
|
||||
clearConnectionHealthCheck(id);
|
||||
@@ -2821,7 +2845,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
}
|
||||
}
|
||||
|
||||
const schemas = sortSidebarSchemaInfos(await api.listSchemaInfos(connectionId, database));
|
||||
const schemas = sortSidebarSchemaInfos(await withMetadataLoadTimeout(connectionId, api.listSchemaInfos(connectionId, database), "schemas"));
|
||||
const visibleSchemaNames = new Set(
|
||||
filterSchemaNamesForConnection(
|
||||
schemas.map((schema) => schema.name),
|
||||
|
||||
Reference in new issue
Block a user