From 9e9957a88b30a8b65e409fe7896d217be4d0d97b Mon Sep 17 00:00:00 2001 From: andykscho Date: Tue, 27 Feb 2024 10:10:27 -0500 Subject: [PATCH] fix the infinite loop on getListOfKernelsWithCachedConnection --- .../jupyter/finder/remoteKernelFinder.ts | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/kernels/jupyter/finder/remoteKernelFinder.ts b/src/kernels/jupyter/finder/remoteKernelFinder.ts index 96d0c876b2b..da057ef2d8d 100644 --- a/src/kernels/jupyter/finder/remoteKernelFinder.ts +++ b/src/kernels/jupyter/finder/remoteKernelFinder.ts @@ -170,32 +170,27 @@ export class RemoteKernelFinder extends DisposableBase implements IRemoteKernelF await this.loadCache(true, true); } - private numberOfFailures = 0; private getListOfKernelsWithCachedConnection( displayProgress: boolean, ignoreCache: boolean = false ): Promise { - const usingCache = !!this.cachedConnection; - this.cachedConnection = this.cachedConnection || this.getRemoteConnectionInfo(displayProgress); + if (!this.cachedConnection || ignoreCache) { + this.cachedConnection = this.getRemoteConnectionInfo(displayProgress); + } return this.cachedConnection .then((connInfo) => { - this.numberOfFailures = 0; - if (connInfo && !usingCache) { + if (connInfo) { this.cachedConnection = Promise.resolve(connInfo); + return this.listKernelsFromConnection(connInfo); } - return connInfo ? this.listKernelsFromConnection(connInfo) : Promise.resolve([]); + return Promise.resolve([]); }) .catch((ex) => { - this.numberOfFailures += 1; if (this.isDisposed) { return Promise.reject(ex); } - if (this.numberOfFailures > 9) { - traceWarning(`Remote Kernel Finder: ${this.id} has failed to connect 10 times in a row.`, ex); - return Promise.reject(ex); - } - if (usingCache) { - return this.getListOfKernelsWithCachedConnection(displayProgress, ignoreCache); + if (!ignoreCache) { + return this.getListOfKernelsWithCachedConnection(displayProgress, true); } this.cachedConnection = undefined; return Promise.reject(ex);