Skip to content

Commit

Permalink
[TS SDK] Fix WebSocket constructor miss in Browser (MystenLabs#16126)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

Reason: 

When using WebSocket in the browser, the value in option is still used
by default.

This will result in an error: 
```
Uncaught Error: Missing WebSocket constructor
```

But in the documentation, it is not mentioned that the constructor needs
to be set to window.WebSocket

So this should be fixed

---------

Co-authored-by: hayes-mysten <[email protected]>
  • Loading branch information
WGB5445 and hayes-mysten authored Feb 8, 2024
1 parent 6b54be8 commit 220a766
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/young-mayflies-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/sui.js': patch
---

Fix WebSocket constructor not being properly assigned in SuiClient HTTP transport
2 changes: 1 addition & 1 deletion sdk/typescript/src/client/http-transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class SuiHTTPTransport implements SuiTransport {
this.#websocketClient = new WebsocketClient(
this.#options.websocket?.url ?? this.#options.url,
{
WebSocketConstructor: this.#options.WebSocketConstructor,
WebSocketConstructor,
...this.#options.websocket,
},
);
Expand Down

0 comments on commit 220a766

Please sign in to comment.