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

Function close

playground/cli-module/__tests__/serve.ts:79–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

77
78 // close server helper, send SIGTERM followed by SIGKILL if needed, give up after 3sec
79 const close = async () => {
80 if (serverProcess) {
81 const timeoutError = `server process still alive after 3s`
82 try {
83 await killProcess(serverProcess)
84 await resolvedOrTimeout(serverProcess, 10000, timeoutError)
85 } catch (e) {
86 if (e === timeoutError || (!serverProcess.killed && !isWindows)) {
87 collectErrorStreams('server', e)
88 console.error(
89 `error while killing cli command "${serverCommand}":`,
90 e,
91 )
92 await printStreamsToConsole('server')
93 }
94 }
95 }
96 }
97
98 try {
99 await startedOnPort(serverProcess, port, 5173)

Callers 1

serveFunction · 0.70

Calls 5

killProcessFunction · 0.85
resolvedOrTimeoutFunction · 0.70
collectErrorStreamsFunction · 0.70
printStreamsToConsoleFunction · 0.70
errorMethod · 0.65

Tested by

no test coverage detected