Vite 6 Breaks server.ws.clients
APIs
#18781
Labels
p3-downstream-blocker
Blocking the downstream ecosystem to work properly (priority)
regression
The issue only appears after a new release
Describe the bug
This is introduced by #18362
The
server.ws.clients
is refactored to be a superset of HotChannelClient which expect a simplesend(payload)
function, but previouslyserver.ws.clients
we also support thesend(event, data)
signature.In
vite-dev-rpc
, the usage is like this:https://github.com/antfu/vite-dev-rpc/blob/b6899623ed19297e5927262396f0d4bfdc34016b/src/index.ts#L17-L32
There are two problems,
server.ws.clients#send
does not supportsend(event, data)
signature, which is addressed by fix(server): recoverserver.ws.clients.send
API changes for back compatibility #18779.socket
fromWebSocketClient
also get lost. By (vite/packages/vite/src/node/server/hmr.ts
Lines 233 to 254 in e26acf4
I am not sure if we should do specially handling for WebSocketServer, or should we also consider that the more general cases:
Due to the normalization made to the client:
NormalizedHotChannelClient
only exposes thesend
function, where theHotChannelClient
is actually an interface that users or other integrations might put more attributes or data in the client (in this case,WebSocketClient
has a.socket
prop)id
or any other field to help identifying, while the instance check might still not working (if we consider it strictly, it might still be a breaking change)?Raised this issue to discuss with design direction we should go to get back the compatibility or capability.
Reproduction
https://github.com/antfu/vite-dev-rpc
Steps to reproduce
Upgrade Vite to 6.0.0 and run
pnpm run dev
, it should show aA + B = C
that calculated on server side.The text was updated successfully, but these errors were encountered: