mswjs / msw

Seamless REST/GraphQL API mocking library for browser and Node.js.
https://mswjs.io
MIT License
15.28k stars 479 forks source link

fix(WebSocketClientManager): use localStorage for clients persistence #2127

Closed kettanaito closed 2 months ago

kettanaito commented 2 months ago

Changes

We have a bug that a new runtime doesn't really know about any other runtimes. It only keeps itself in the list of clients and notifies other runtimes about itself. That's not right.

BroadcastChannel is not a good API to introduce a shared state because one has to constantly keep that state in-sync. Instead, I propose we use localStorage to keep the serialized list of all the WebSocket clients for the app.

Roadmap