From 5028169e636f8cf60ef99b299a489c291917e0c8 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 9 Sep 2022 10:47:57 -0700 Subject: [PATCH] refactor: heartbeat patch (#5545) --- patches/heartbeat.diff | 37 ------------------------------------- patches/series | 1 - 2 files changed, 38 deletions(-) delete mode 100644 patches/heartbeat.diff diff --git a/patches/heartbeat.diff b/patches/heartbeat.diff deleted file mode 100644 index c8d619140..000000000 --- a/patches/heartbeat.diff +++ /dev/null @@ -1,37 +0,0 @@ -Add a heartbeat to web socket connections - -This prevents them from being killed when they are idle. To test run behind -NGINX, make sure the sockets are idle (check dev tools), then wait 60+ seconds. - -Index: code-server/lib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts -=================================================================== ---- code-server.orig/lib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts -+++ code-server/lib/vscode/src/vs/base/parts/ipc/common/ipc.net.ts -@@ -7,6 +7,7 @@ import { VSBuffer } from 'vs/base/common - import { Emitter, Event } from 'vs/base/common/event'; - import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle'; - import { IIPCLogger, IMessagePassingProtocol, IPCClient } from 'vs/base/parts/ipc/common/ipc'; -+import { isWeb } from 'vs/base/common/platform'; - - export const enum SocketDiagnosticsEventType { - Created = 'created', -@@ -849,6 +850,19 @@ export class PersistentProtocol implemen - this._socketDisposables.push(this._socketWriter); - this._socketReader = new ProtocolReader(this._socket); - this._socketDisposables.push(this._socketReader); -+ // Send empty messages to keep the socket alive. We only need this on the -+ // web where sockets can be killed by reverse proxies for inactivity. -+ if (isWeb) { -+ const timer = setInterval(() => { -+ const msg = new ProtocolMessage(ProtocolMessageType.None, 0, 0, getEmptyBuffer()); -+ this._socketWriter.write(msg); -+ }, 45000); // NGINX has a 60 second default timeout so try 45 seconds. -+ this._socketDisposables.push({ -+ dispose: () => { -+ clearInterval(timer); -+ }, -+ }); -+ } - this._socketDisposables.push(this._socketReader.onMessage(msg => this._receiveMessage(msg))); - this._socketDisposables.push(this._socket.onClose((e) => this._onSocketClose.fire(e))); - if (initialChunk) { diff --git a/patches/series b/patches/series index c8f1bb595..8a5e32ee3 100644 --- a/patches/series +++ b/patches/series @@ -20,6 +20,5 @@ disable-downloads.diff telemetry.diff display-language.diff cli-window-open.diff -heartbeat.diff exec-argv.diff safari-console.diff