Skip to content

chore: Make ws dependency optional for node.js environments - #288

Merged
jimmycallin merged 2 commits into
mainfrom
ws-optional
Mar 11, 2025
Merged

chore: Make ws dependency optional for node.js environments#288
jimmycallin merged 2 commits into
mainfrom
ws-optional

Conversation

@jimmycallin

@jimmycallin jimmycallin commented Mar 11, 2025

Copy link
Copy Markdown
Contributor
  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

As Node >= 21 has a built-in websocket client, it's preferable to not having to rely on the ws dependency through isomorphic-ws for Node, but rather check if WebSocket is available in the global namespace, and only load ws if not.

Once Node 20 becomes EOL (2026-04-30) we can remove ws as well and only rely on undici's WebSocket.

Test

@jimmycallin
jimmycallin requested a review from a team March 11, 2025 09:30
Comment thread vitest.setup.js

beforeAll(() => {
server.listen({ onUnhandledRequest: "bypass" });
global.fetch = fetch;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftovers from when we removed cross-fetch

Comment thread vitest.setup.js
beforeAll(() => {
server.listen({ onUnhandledRequest: "bypass" });
global.fetch = fetch;
server.listen({ onUnhandledRequest: "error" });

@jimmycallin jimmycallin Mar 11, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now when websocket updates are handled natively, we can do "error" again 🥳

@jimmycallin
jimmycallin requested a review from gismya March 11, 2025 09:38

@gismya gismya left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@jimmycallin
jimmycallin merged commit 16ccdd6 into main Mar 11, 2025
@jimmycallin
jimmycallin deleted the ws-optional branch March 11, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants