diff options
author | 2022-10-01 18:06:01 -0700 | |
---|---|---|
committer | 2022-10-01 18:06:01 -0700 | |
commit | bff3b902e8b55296d785e7224652de78d14914c2 (patch) | |
tree | 91c60acadc2d3551a57e2dccf94871407d92ed1d /src | |
parent | 3b4900193ba4a6ee40b3d5935650b5f68baf0729 (diff) | |
download | bun-bff3b902e8b55296d785e7224652de78d14914c2.tar.gz bun-bff3b902e8b55296d785e7224652de78d14914c2.tar.zst bun-bff3b902e8b55296d785e7224652de78d14914c2.zip |
Fix unref'ing websocket
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/api/bun.zig | 2 | ||||
-rw-r--r-- | src/http/websocket_http_client.zig | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 5c8bfbb0e..7044b9258 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -2202,6 +2202,8 @@ pub const Timer = struct { last_id: i32 = 1, warned: bool = false, + // We split up the map here to avoid storing an extra "repeat" boolean + /// Used by setTimeout() timeout_map: TimeoutMap = TimeoutMap{}, diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index 2dfed4d7a..b1b4eea4b 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -790,6 +790,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { } pub fn clearData(this: *WebSocket) void { + this.poll_ref.unref(this.globalThis.bunVM()); this.clearReceiveBuffers(true); this.clearSendBuffers(true); this.ping_len = 0; @@ -1371,6 +1372,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { fn dispatchClose(this: *WebSocket) void { var out = this.outgoing_websocket orelse return; + this.poll_ref.unref(this.globalThis.bunVM()); JSC.markBinding(); WebSocket__didCloseWithErrorCode(out, ErrorCode.closed); } @@ -1459,8 +1461,6 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { pub fn finalize(this: *WebSocket) callconv(.C) void { this.clearData(); - this.poll_ref.unref(this.globalThis.bunVM()); - this.outgoing_websocket = null; if (this.tcp.isClosed()) |