Skip to content

Commit

Permalink
Use native WebSocket in server runtimes that support it (#2500)
Browse files Browse the repository at this point in the history
* Use native `WebSocket` in server runtimes that support it

* Create witty-camels-remember.md
  • Loading branch information
steveluscher authored Apr 16, 2024
1 parent c1ae0f1 commit 82c57c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/witty-camels-remember.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solana/ws-impl": patch
---

Use native `WebSocket` for compatibility with server runtimes that support it, like Deno
4 changes: 3 additions & 1 deletion packages/ws-impl/src/index.node.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// When building the browser bundle, this import gets replaced by `globalThis.WebSocket`.
import WebSocketImpl from 'ws';

export default WebSocketImpl;
export default globalThis.WebSocket
? globalThis.WebSocket // Use native `WebSocket` in runtimes that support it (eg. Deno)
: WebSocketImpl;

0 comments on commit 82c57c6

Please sign in to comment.