S
SolidJS15mo ago
belst

hmr and WebSockets

hi, when trying to use websockets during development, it can take up to 20 seconds for the socket to connect after an hmr reload. Can I somehow not try to keep the websocket state during hmr and just reconnect?
3 Replies
Alex Lohr
Alex Lohr15mo ago
The root component is not reloaded unless changed. If you instantiate the web socket there, it should be kept.
belst
belstOP15mo ago
it's not in the root component. The issue is, that when I reload or change anything, it takes ages for the socket to connect. if I build then serve, it works instantly everytime. I can console.log(ws) directly after creating it, but the onopen event triggers extremly late or not at all when using build + serve it works instantly
Alex Lohr
Alex Lohr15mo ago
That's because HMR unloads and reloads every component in files that changed. The unloading could be taking some extra time.
Want results from more Discord servers?
Add your server