Skip to content

Fixed heap out of memory on network issues#39

Open
aizo231 wants to merge 3 commits into
Polymarket:mainfrom
aizo231:patch-2
Open

Fixed heap out of memory on network issues#39
aizo231 wants to merge 3 commits into
Polymarket:mainfrom
aizo231:patch-2

Conversation

@aizo231
Copy link
Copy Markdown

@aizo231 aizo231 commented Feb 27, 2026

Heap out of memory error happened, because WebSocket instance was not terminated when establishing new one, leading to massive spike in memory on network errors.


Note

Medium Risk
Changes WebSocket lifecycle/reconnect behavior by terminating and nulling sockets on error/close, which could affect reconnect timing and any downstream assumptions about ws being non-null.

Overview
Improves RealTimeDataClient resilience to network failures by explicitly cleaning up WebSocket instances on error and close (remove listeners, terminate(), and clear ws) before attempting auto-reconnect, preventing buildup of orphaned sockets and memory growth.

Adds guards so ping() and the pong-driven ping loop only run when a socket exists, and ensures DISCONNECTED status is emitted on errors as well as closes.

Written by Cursor Bugbot for commit 01d1d6e. This will update automatically on new commits. Configure here.

Heap out of memory error happened, because WebSocket instance was not terminated when establishing new one, leading to massive spike in memory on network errors.
Comment thread src/client.ts
Comment thread src/client.ts
I could seperate it into two commits right?
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/client.ts
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.

1 participant