Skip to content

Commit 3faf1c5

Browse files
authored
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 <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # 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. <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> 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 <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! -->
1 parent 1733145 commit 3faf1c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

sdks/typescript/packages/sdk/src/websocket_decompress_adapter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export class WebsocketDecompressAdapter {
3737
this.onerror?.(msg);
3838
}
3939

40+
#handleOnClose(msg: any) {
41+
this.onclose?.(msg);
42+
}
43+
4044
send(msg: any): void {
4145
this.#ws.send(msg);
4246
}
@@ -53,7 +57,7 @@ export class WebsocketDecompressAdapter {
5357

5458
ws.onmessage = this.#handleOnMessage.bind(this);
5559
ws.onerror = this.#handleOnError.bind(this);
56-
ws.onclose = this.#handleOnError.bind(this);
60+
ws.onclose = this.#handleOnClose.bind(this);
5761
ws.onopen = this.#handleOnOpen.bind(this);
5862

5963
ws.binaryType = 'arraybuffer';

0 commit comments

Comments
 (0)