fix(plugins): self-heal restored plugin pages silently
This commit is contained in:
1 parent
397bff26c8
commit
53cd0c516e
5 files changed
+235
-20
No files matched your search
@@ -56,7 +56,8 @@ async function load() {
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
async function refresh(options: { silent?: boolean } = {}) {
|
||||
const silent = options.silent === true;
|
||||
deferred.value = false;
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
@@ -67,25 +68,51 @@ async function refresh() {
|
||||
// The connection is open but the plugin sidecar's registry may have
|
||||
// been wiped (iframe reload, tab restore): ensureConnected's health
|
||||
// fast-path only probes the sidecar process and would not heal that.
|
||||
// Force a re-push instead; it no-ops when a push just happened.
|
||||
await connectionStore.repushPluginConnection(connectionId);
|
||||
// Force a re-push instead; it no-ops when a push just happened. A
|
||||
// silent restore additionally overrides the recent-health TTL: the
|
||||
// SPA's boot restore can mark the connection healthy without ever
|
||||
// delivering credentials to the sidecar, and a skipped push here
|
||||
// strands the restored plugin with an empty registry
|
||||
// (dbx-plugin-ssh#144).
|
||||
const pushed = await connectionStore.repushPluginConnection(connectionId, { ignoreRecentHealthCheck: silent });
|
||||
if (silent && pushed === false) {
|
||||
loading.value = false;
|
||||
deferred.value = true;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
await connectionStore.ensureConnected(connectionId);
|
||||
await connectionStore.ensureConnected(connectionId, silent ? { allowPasswordPrompt: false } : undefined);
|
||||
}
|
||||
}
|
||||
await load();
|
||||
} catch (cause) {
|
||||
loading.value = false;
|
||||
if (silent) {
|
||||
// Silent recovery (tab restore after a page refresh, or a workbench
|
||||
// opened for a not-yet-connected connection) must not surface an error
|
||||
// card nor trigger an interactive credential prompt from the background:
|
||||
// park on the explicit reload prompt so the user can retry
|
||||
// interactively (dbx-plugin-ssh#144).
|
||||
error.value = "";
|
||||
deferred.value = !!resolvedConnectionId.value;
|
||||
return;
|
||||
}
|
||||
error.value = cause instanceof Error ? cause.message : String(cause);
|
||||
}
|
||||
}
|
||||
|
||||
function start() {
|
||||
const connectionId = resolvedConnectionId.value;
|
||||
deferred.value = !!connectionId && !connectionStore.connectedIds.has(connectionId);
|
||||
if (deferred.value) {
|
||||
loading.value = false;
|
||||
error.value = "";
|
||||
if (connectionId && !connectionStore.connectedIds.has(connectionId)) {
|
||||
// A restored tab (page refresh) or a link for a closed connection used to
|
||||
// park here from a one-shot snapshot: even when the SPA's boot connect
|
||||
// replay landed a moment later nothing re-checked, so the tab dead-ended
|
||||
// on the reload prompt and the plugin could never re-establish its
|
||||
// session (dbx-plugin-ssh#144). Self-heal silently instead — the Refresh
|
||||
// button's path minus interactive prompts — and only park when silent
|
||||
// recovery cannot proceed (interactive credentials required, connection
|
||||
// gone).
|
||||
void refresh({ silent: true });
|
||||
return;
|
||||
}
|
||||
void load();
|
||||
|
||||
Reference in new issue
Block a user