浏览代码

fix: remove the 3-second startup delay of the kernel connection (#10321)

The logic for immediately sending a kernel info message on restart
is also applied when starting. The kernel info request in the
constructor is removed because it is redundant (this message is
also send on the web socket open event) and causes a
"status is not connected" console error on startup in the new
situation.
Mario Buikhuizen 3 年之前
父节点
当前提交
96b6ca109f
共有 1 个文件被更改,包括 5 次插入6 次删除
  1. 5 6
      packages/services/src/kernel/default.ts

+ 5 - 6
packages/services/src/kernel/default.ts

@@ -33,6 +33,7 @@ declare let requirejs: any;
 
 const KERNEL_INFO_TIMEOUT = 3000;
 const RESTARTING_KERNEL_SESSION = '_RESTARTING_';
+const STARTING_KERNEL_SESSION = '';
 
 /**
  * Implementation of the Kernel object.
@@ -56,9 +57,6 @@ export class KernelConnection implements Kernel.IKernelConnection {
     this.handleComms = options.handleComms ?? true;
 
     this._createSocket();
-
-    // Immediately queue up a request for initial kernel info.
-    void this.requestKernelInfo();
   }
 
   get disposed(): ISignal<this, void> {
@@ -395,13 +393,14 @@ export class KernelConnection implements Kernel.IKernelConnection {
       throw new Error('Kernel is dead');
     }
 
-    // If we have a kernel_info_request and we are restarting, send the
+    // If we have a kernel_info_request and we are starting or restarting, send the
     // kernel_info_request immediately if we can, and if not throw an error so
-    // we can retry later. We do this because we must get at least one message
+    // we can retry later. On restarting we do this because we must get at least one message
     // from the kernel to reset the kernel session (thus clearing the restart
     // status sentinel).
     if (
-      this._kernelSession === RESTARTING_KERNEL_SESSION &&
+      (this._kernelSession === STARTING_KERNEL_SESSION ||
+        this._kernelSession === RESTARTING_KERNEL_SESSION) &&
       KernelMessage.isInfoRequestMsg(msg)
     ) {
       if (this.connectionStatus === 'connected') {