Skip to content

Commit 41d83de

Browse files
committed
Always delete cached authentication promise when request fails (fix intersystems-community#1196)
1 parent 0916d94 commit 41d83de

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/api/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,19 @@ export class AtelierAPI {
435435

436436
return data;
437437
} catch (error) {
438-
if (error.code === "ECONNREFUSED") {
439-
authRequestMap.delete(target);
438+
// always discard the cached authentication promise
439+
authRequestMap.delete(target);
440+
441+
// In some cases schedule an automatic retry.
442+
// ENOTFOUND occurs if, say, the VPN to the server's network goes down.
443+
if (error.code === "ECONNREFUSED" || error.code === "ENOTFOUND") {
440444
panel.text = `${this.connInfo} $(debug-disconnect)`;
441445
panel.tooltip = "Disconnected";
442446
workspaceState.update(this.configName.toLowerCase() + ":host", undefined);
443447
workspaceState.update(this.configName.toLowerCase() + ":port", undefined);
444448
if (!checkingConnection) {
445449
setTimeout(() => checkConnection(false, undefined, true), 30000);
446450
}
447-
} else if (error.code === "EPROTO") {
448-
// This can happen if https was configured but didn't work
449-
authRequestMap.delete(target);
450451
}
451452
throw error;
452453
}

0 commit comments

Comments
 (0)