Skip to content

Commit 9415001

Browse files
committed
Disable Nagle's algorithm for web sockets
1 parent 2c9f5fe commit 9415001

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/vs/platform/remote/common/remoteAgentConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ export abstract class PersistentConnection extends Disposable {
573573
}));
574574
this._register(protocol.onSocketTimeout(() => {
575575
const logPrefix = commonLogPrefix(this._connectionType, this.reconnectionToken, true);
576-
this._options.logService.trace(`${logPrefix} received socket timeout event.`);
576+
this._options.logService.info(`${logPrefix} received socket timeout event.`);
577577
this._beginReconnecting();
578578
}));
579579

src/vs/platform/remote/node/nodeSocketFactory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const nodeSocketFactory = new class implements ISocketFactory {
2121
}
2222
const nonce = buffer.toString('base64');
2323

24-
let headers = [
24+
const headers = [
2525
`GET ws://${/:/.test(host) ? `[${host}]` : host}:${port}/?${query}&skipWebSocketFrames=true HTTP/1.1`,
2626
`Connection: Upgrade`,
2727
`Upgrade: websocket`,
@@ -39,6 +39,8 @@ export const nodeSocketFactory = new class implements ISocketFactory {
3939
};
4040
socket.on('data', onData);
4141
});
42+
// Disable Nagle's algorithm.
43+
socket.setNoDelay(true);
4244
socket.once('error', errorListener);
4345
}
4446
};

src/vs/server/remoteExtensionHostAgentServer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ export class RemoteExtensionHostAgentServer extends Disposable {
497497

498498
// Never timeout this socket due to inactivity!
499499
socket.setTimeout(0);
500+
// Disable Nagle's algorithm
501+
socket.setNoDelay(true);
500502
// Finally!
501503

502504
if (skipWebSocketFrames) {

src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ function _createExtHostProtocol(): Promise<PersistentProtocol> {
120120

121121
process.on('message', (msg: IExtHostSocketMessage | IExtHostReduceGraceTimeMessage, handle: net.Socket) => {
122122
if (msg && msg.type === 'VSCODE_EXTHOST_IPC_SOCKET') {
123+
// Disable Nagle's algorithm. We also do this on the server process,
124+
// but nodejs doesn't document if this option is transferred with the socket
125+
handle.setNoDelay(true);
126+
123127
const initialDataChunk = VSBuffer.wrap(Buffer.from(msg.initialDataChunk, 'base64'));
124128
let socket: NodeSocket | WebSocketNodeSocket;
125129
if (msg.skipWebSocketFrames) {

0 commit comments

Comments
 (0)