From 3faf1c59cb2a1094de0bae73a8f87dc474fb1836 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 11 Aug 2025 09:51:41 -0700 Subject: [PATCH] Typescript SDK: Fix to actually use the passed onclose function (#3152) # Description of Changes Fixes a Typescript SDK bug where onclose of WebsocketDecompressAdapter is never called # API and ABI breaking changes None # Expected complexity level and risk Potential risk as Typescript SDK consumers might be currently relying only on onConnectError to report disconnection. Users should instead use onDisconnect, or can simply subscribe to both callbacks with the same function again to get the same functionality. This is a trivial change, but could have minor repercussions on current code. I'd still say it's a level 1 change, with consumers able to easily change to the correct callback. # Testing --- .../packages/sdk/src/websocket_decompress_adapter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdks/typescript/packages/sdk/src/websocket_decompress_adapter.ts b/sdks/typescript/packages/sdk/src/websocket_decompress_adapter.ts index fbd1d0faf8..efc780713b 100644 --- a/sdks/typescript/packages/sdk/src/websocket_decompress_adapter.ts +++ b/sdks/typescript/packages/sdk/src/websocket_decompress_adapter.ts @@ -37,6 +37,10 @@ export class WebsocketDecompressAdapter { this.onerror?.(msg); } + #handleOnClose(msg: any) { + this.onclose?.(msg); + } + send(msg: any): void { this.#ws.send(msg); } @@ -53,7 +57,7 @@ export class WebsocketDecompressAdapter { ws.onmessage = this.#handleOnMessage.bind(this); ws.onerror = this.#handleOnError.bind(this); - ws.onclose = this.#handleOnError.bind(this); + ws.onclose = this.#handleOnClose.bind(this); ws.onopen = this.#handleOnOpen.bind(this); ws.binaryType = 'arraybuffer';