diff --git a/.changeset/witty-camels-remember.md b/.changeset/witty-camels-remember.md new file mode 100644 index 000000000000..6fb330c94fa2 --- /dev/null +++ b/.changeset/witty-camels-remember.md @@ -0,0 +1,5 @@ +--- +"@solana/ws-impl": patch +--- + +Use native `WebSocket` for compatibility with server runtimes that support it, like Deno diff --git a/packages/ws-impl/src/index.node.ts b/packages/ws-impl/src/index.node.ts index cb4d0c100e3a..92c4403f3228 100644 --- a/packages/ws-impl/src/index.node.ts +++ b/packages/ws-impl/src/index.node.ts @@ -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;