fix(core): allocate standalone WebSocket ports atomically - #520
fix(core): allocate standalone WebSocket ports atomically#520webfansplz wants to merge 3 commits into
Conversation
@vitejs/devtools
@vitejs/devtools-kit
@vitejs/devtools-oxc
@vitejs/devtools-rolldown
@vitejs/devtools-vite
@vitejs/devtools-vitest
commit: |
There was a problem hiding this comment.
Pull request overview
This PR fixes a race condition in standalone WebSocket port selection for Vite DevTools by removing probe-before-bind logic and relying on the underlying Devframe WS transport to bind atomically (port 0 → OS-assigned port), then publishing the resolved endpoint for remote docks.
Changes:
- Remove
get-port-pleasepre-allocation and delegate default standalone port selection to the Devframe transport. - Await transport readiness and read back the actual bound port from
transport.address(). - Publish the resolved WS endpoint and re-emit remote dock update events once the endpoint is known.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f054ea3 to
932e70b
Compare
|
Thanks for this fix! As of #529, the standalone WebSocket server previously at Good news: the atomic-port-binding half of this fix already shipped there — devframes/devframe#171 (merged) binds standalone transports to port Thank you for tracking down #517 and flagging the upstream dependency yourself — we're crediting you as the original author on the linked issue. Closing this one in spirit since the bulk of the fix already landed; follow devframes/devframe#206 for the remainder. |
Vite DevTools previously selected a standalone WebSocket port with
get-port-pleasebefore starting the server. Concurrent processes could probe the same available port and then race to bind it, causing all but one to fail withEADDRINUSE.Default port allocation is now delegated to the Devframe transport, which binds to port
0and lets the operating system select and reserve an available port atomically.Changes
Standalone environments that require a stable port can continue to configure
websocket.portexplicitly.Waitting for devframes/devframe#171, Fix #517