Change:
When connecting to a remote, if the initial connection fails, we will give up. The idea was that retrying would be useless, since the initial setup might have failed. But it is possible that perhaps it was an intermittent network error.
One of the annoyances I have is all my open editors tabs are closed. I have to try and remember what editor tabs I had open which often leads to lost time and effort trying to recall. I did create a ticket for this, which is how I found this as it was suggested, Ideally, even if can't connect need the ability to save/restore the prior editor tabs that were open or currently opened.
This can be verified running from source with the test resolver, using a change like the following: Then, run and from the bottom left open the test resolver. The resulting window should connect despite the resolver returning errors or resolving with an address which leads to a connection error.

Discussion:
} export async function connectRemoteAgentManagement(options: IConnectionOptions, remoteAuthority: string, clientId: string): Promise<ManagementPersistentConnection> { <del> try { const reconnectionToken = generateUuid(); const simpleOptions = await resolveConnectionOptions(options, reconnectionToken, null); const { protocol } = await doConnectRemoteAgentManagement(simpleOptions, CancellationToken.None); return new ManagementPersistentConnection(options, remoteAuthority, clientId, reconnectionToken, protocol); } catch (err) { options.logService.error(`[remote-connection] An error occurred in the very first connect attempt, it will be treated as a permanent error! Error:`); options.logService.error(err); PersistentConnection.triggerPermanentFailure(0, 0, RemoteAuthorityResolverError.isHandled(err)); throw err; } </del> <ins> return createInitialConnection( options, async (simpleOptions) => { const { protocol } = await doConnectRemoteAgentManagement(simpleOptions, CancellationToken.None); return new ManagementPersistentConnection(options, remoteAuthority, clientId, simpleOptions.reconnectionToken, protocol); } ); </ins> } export async function connectRemoteAgentExtensionHost(options: IConnectionOptions, startArguments: IRemoteExtensionHostStartParams): Promise<ExtensionHostPersistentConnection> { <del> try { const reconnectionToken = generateUuid(); const simpleOptions = await resolveConnectionOptions(options, reconnectionToken, null); const { protocol, debugPort } = await doConnectRemoteAgentExtensionHost(simpleOptions, startArguments, CancellationToken.None); return new ExtensionHostPersistentConnection(options, startArguments, reconnectionToken, protocol, debugPort); } catch (err) { options.logService.error(`[remote-connection] An error occurred in the very first connect attempt, it will be treated as a permanent error! Error:`); options.logService.error(err); PersistentConnection.triggerPermanentFailure(0, 0, RemoteAuthorityResolverError.isHandled(err)); throw err; </del> <ins> return createInitialConnection( options, async (simpleOptions) => { const { protocol, debugPort } = await doConnectRemoteAgentExtensionHost(simpleOptions, startArguments, CancellationToken.None); return new ExtensionHostPersistentConnection(options, startArguments, simpleOptions.reconnectionToken, protocol, debugPort); } ); } /** * Will attempt to connect 5 times. If it fails 5 consecutive times, it will give up. */ async function createInitialConnection<T extends PersistentConnection>(options: IConnectionOptions, connectionFactory: (simpleOptions: ISimpleConnectionOptions) => Promise<T>): Promise<T> { const MAX_ATTEMPTS = 5; for (let attempt = 1; ; attempt++) { try { const reconnectionToken = generateUuid(); const simpleOptions = await resolveConnectionOptions(options, reconnectionToken, null); const result = await connectionFactory(simpleOptions); return result; } catch (err) { if (attempt < MAX_ATTEMPTS) { options.logService.error(`[remote-connection][attempt ${attempt}] An error occurred in initial connection! Will retry... Error:`); options.logService.error(err); } else { options.logService.error(`[remote-connection][attempt ${attempt}]  An error occurred in initial connection! It will be treated as a permanent error. Error:`); options.logService.error(err); PersistentConnection.triggerPermanentFailure(0, 0, RemoteAuthorityResolverError.isHandled(err)); throw err; } } </ins> } }

throw new Error(`Cannot get canonical URI because no extension is installed to resolve ${getRemoteAuthorityPrefix(remoteAuthority)}`); } <ins> private async _resolveAuthorityInitial(remoteAuthority: string): Promise<ResolverResult> { const MAX_ATTEMPTS = 5; for (let attempt = 1; ; attempt++) { const sw = StopWatch.create(false); this._logService.info(`[attempt ${attempt}] Invoking resolveAuthority(${getRemoteAuthorityPrefix(remoteAuthority)})`); try { const resolverResult = await this._resolveAuthority(remoteAuthority); this._logService.info(`[attempt ${attempt}] resolveAuthority(${getRemoteAuthorityPrefix(remoteAuthority)}) returned '${resolverResult.authority.host}:${resolverResult.authority.port}' after ${sw.elapsed()} ms`); return resolverResult; } catch (err) { this._logService.error(`[attempt ${attempt}] resolveAuthority(${getRemoteAuthorityPrefix(remoteAuthority)}) returned an error after ${sw.elapsed()} ms`, err); if (RemoteAuthorityResolverError.isNoResolverFound(err)) { // There is no point in retrying if there is no resolver found throw err; } if (attempt >= MAX_ATTEMPTS) { // Too many failed attempts, give up throw err; } } } } </ins> private async _resolveAuthorityAgain(): Promise<void> { const remoteAuthority = this._environmentService.remoteAuthority; if (!remoteAuthority) {

} let resolverResult: ResolverResult; <del> const sw = StopWatch.create(false); this._logService.info(`Invoking resolveAuthority(${getRemoteAuthorityPrefix(remoteAuthority)})`); </del> try { <del> resolverResult = await this._resolveAuthority(remoteAuthority); this._logService.info(`resolveAuthority(${getRemoteAuthorityPrefix(remoteAuthority)}) returned '${resolverResult.authority.host}:${resolverResult.authority.port}' after ${sw.elapsed()} ms`); </del> <ins> resolverResult = await this._resolveAuthorityInitial(remoteAuthority); </ins> } catch (err) { <del> this._logService.error(`resolveAuthority(${getRemoteAuthorityPrefix(remoteAuthority)}) returned an error after ${sw.elapsed()} ms`, err); </del> if (RemoteAuthorityResolverError.isNoResolverFound(err)) { err.isHandled = await this._handleNoResolverFound(remoteAuthority); } else {