diff --git a/news/2 Fixes/9926.md b/news/2 Fixes/9926.md new file mode 100644 index 000000000000..c609b86c388b --- /dev/null +++ b/news/2 Fixes/9926.md @@ -0,0 +1 @@ +Use the autoStart server when available. diff --git a/src/client/datascience/jupyter/liveshare/serverCache.ts b/src/client/datascience/jupyter/liveshare/serverCache.ts index 663452536af5..b9390fd6d311 100644 --- a/src/client/datascience/jupyter/liveshare/serverCache.ts +++ b/src/client/datascience/jupyter/liveshare/serverCache.ts @@ -17,6 +17,7 @@ interface IServerData { options: INotebookServerOptions; promise: Promise; cancelSource: CancellationTokenSource; + resolved: boolean; } export class ServerCache implements IAsyncDisposable { @@ -43,7 +44,7 @@ export class ServerCache implements IAsyncDisposable { // See if the old options had the same UI setting. If not, // cancel the old - if (data && data.options.disableUI !== fixedOptions.disableUI) { + if (data && !data.resolved && data.options.disableUI !== fixedOptions.disableUI) { traceInfo('Cancelling server create as UI state has changed'); data.cancelSource.cancel(); data = undefined; @@ -55,7 +56,8 @@ export class ServerCache implements IAsyncDisposable { data = { promise: createFunction(options, cancelSource.token), options: fixedOptions, - cancelSource + cancelSource, + resolved: false }; this.cache.set(key, data); } @@ -75,6 +77,11 @@ export class ServerCache implements IAsyncDisposable { return oldDispose(); }; + // We've resolved the promise at this point + if (data) { + data.resolved = true; + } + return server; }) .catch(e => {