Skip to content

fix: stop unbounded websocket inflate-byte recording#293819

Merged
alexdima merged 2 commits intomicrosoft:mainfrom
SongXiaoXi:main
Feb 11, 2026
Merged

fix: stop unbounded websocket inflate-byte recording#293819
alexdima merged 2 commits intomicrosoft:mainfrom
SongXiaoXi:main

Conversation

@SongXiaoXi
Copy link
Contributor

@SongXiaoXi SongXiaoXi commented Feb 9, 2026

This pull request adds the ability to dynamically enable or disable recording of inflated bytes in WebSocket communication, and ensures that this recording is properly disabled and cleaned up in key server-side scenarios. The main changes include introducing a new method for toggling this recording, propagating this control through the relevant classes, and improving resource cleanup during disposal.

I hit an unbounded memory growth issue in code-server (up to ~90GB RSS in 2 days) that appears to match the behavior described in #234806, and this PR includes a fix.

Dynamic inflate byte recording control:

  • Added a setRecordInflateBytes(record: boolean) method to WebSocketNodeSocket, WebSocketFlowManager, and ZlibInflateStream to allow toggling the recording of inflated bytes at runtime. When disabled, any previously recorded bytes are cleared.

Resource cleanup improvements:

  • Enhanced the dispose() methods of both ZlibInflateStream and ZlibDeflateStream to clear internal buffers and safely close zlib streams, guarding against errors during disposal.

Copilot AI review requested due to automatic review settings February 9, 2026 07:37
@vs-code-engineering
Copy link

vs-code-engineering bot commented Feb 9, 2026

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/base/parts/ipc/node/ipc.net.ts
  • src/vs/base/parts/ipc/test/node/ipc.net.test.ts

@SongXiaoXi
Copy link
Contributor Author

@microsoft-github-policy-service agree

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a runtime switch to stop recording “inflate seed” bytes for WebSocket permessage-deflate once they’re no longer needed, preventing unbounded memory growth in long-lived server-side WebSocket scenarios (notably management/tunnel connections and post-handoff to the extension host process).

Changes:

  • Introduces setRecordInflateBytes(record: boolean) on WebSocketNodeSocket, WebSocketFlowManager, and ZlibInflateStream, clearing previously recorded bytes when disabled.
  • Disables inflate-byte recording for server-side management and tunnel connections, and after capturing the seed bytes used for extension-host socket handoff.
  • Improves zlib stream cleanup by clearing internal buffers and closing zlib streams during disposal.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/vs/server/node/remoteExtensionHostAgentServer.ts Disables inflate-byte recording for management and tunnel WebSocket connections to prevent long-lived accumulation.
src/vs/server/node/extensionHostConnection.ts Disables recording after capturing seed bytes for socket handoff; also disables recording when socket passing isn’t possible.
src/vs/base/parts/ipc/node/ipc.net.ts Adds the toggle API through the WebSocket stack and strengthens zlib stream disposal to clear buffers/close streams.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@SongXiaoXi
Copy link
Contributor Author

Hi, @alexdima. all review feedback is addressed and CI is green. Would you mind taking a look when you have a moment? Thanks.

@alexdima alexdima added this to the February 2026 milestone Feb 11, 2026
Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! Thank you!

@alexdima alexdima merged commit eb20333 into microsoft:main Feb 11, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants