MCPcopy
hub / github.com/web-infra-dev/rsbuild / close

Method close

packages/core/src/server/socketServer.ts:337–368  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

335 }
336
337 public async close(): Promise<void> {
338 this.clearHeartbeatTimer();
339
340 // Remove all event listeners
341 this.wsServer.removeAllListeners();
342
343 // Close all client sockets
344 for (const socket of this.wsServer.clients) {
345 socket.terminate();
346 }
347 // Close all tracked sockets
348 for (const sockets of this.socketsMap.values()) {
349 sockets.forEach((socket) => {
350 socket.close();
351 });
352 }
353
354 // Reset all properties
355 this.socketsMap.clear();
356 this.initialChunksMap.clear();
357 this.reportedBrowserLogs.clear();
358
359 return new Promise<void>((resolve, reject) => {
360 this.wsServer.close((err) => {
361 if (err) {
362 reject(err);
363 } else {
364 resolve();
365 }
366 });
367 });
368 }
369
370 private onConnect(socket: ExtWebSocket, token: string) {
371 socket.isAlive = true;

Callers 15

onChangeFunction · 0.45
buildFunction · 0.45
buildFunction · 0.45
onEscKeydownMethod · 0.45
clearOverlayFunction · 0.45
setupCommandsFunction · 0.45
setupCliShortcutsFunction · 0.45
closeFunction · 0.45
watchDevFilesFunction · 0.45
getDevMiddlewaresFunction · 0.45
getPortFunction · 0.45
getServerTerminatorFunction · 0.45

Calls 1

clearHeartbeatTimerMethod · 0.95

Tested by 4

closeServerFunction · 0.36
occupyPortFunction · 0.36
occupyPortFunction · 0.36
closeFunction · 0.36