MCPcopy
hub / github.com/vitejs/vite / handleUpgrade

Function handleUpgrade

packages/vite/src/node/server/ws.ts:200–216  ·  view source on GitHub ↗
(
    req: IncomingMessage,
    socket: Duplex,
    head: Buffer,
    isPing: boolean,
  )

Source from the content-addressed store, hash-verified

198 return true
199 }
200 const handleUpgrade = (
201 req: IncomingMessage,
202 socket: Duplex,
203 head: Buffer,
204 isPing: boolean,
205 ) => {
206 wss.handleUpgrade(req, socket as Socket, head, (ws) => {
207 // vite-ping is allowed to connect from anywhere
208 // we close the connection immediately without connection event
209 // so that the client does not get included in `wss.clients`
210 if (isPing) {
211 ws.close(/* Normal Closure */ 1000)
212 return
213 }
214 wss.emit('connection', ws, req)
215 })
216 }
217 const wss: WebSocketServerRaw_ = new WebSocketServerRaw({ noServer: true })
218 wss.shouldHandle = shouldHandle
219

Callers 1

createWebSocketServerFunction · 0.85

Calls 1

closeMethod · 0.65

Tested by

no test coverage detected