MCPcopy
hub / github.com/vercel/next.js / stopApp

Function stopApp

test/lib/next-test-utils.ts:693–714  ·  view source on GitHub ↗
(server: http.Server | undefined)

Source from the content-addressed store, hash-verified

691}
692
693export async function stopApp(server: http.Server | undefined) {
694 if (!server) {
695 return
696 }
697
698 if (server['__app']) {
699 await server['__app'].close()
700 }
701
702 // Node.js's http::close() prevents new connections from being accepted,
703 // but doesn't close existing connections and if there are any leftover
704 // whole process teardown will wait until it's being closed.
705 // Instead, force close connections since this is teardown fn that we expect
706 // any connections to be closed already.
707 server['__socketSet']?.forEach(function (socket) {
708 if (!socket.closed && !socket.destroyed) {
709 socket.destroy()
710 }
711 })
712
713 await promisify(server.close).apply(server)
714}
715
716export async function waitFor(
717 millisOrCondition: number | (() => boolean)

Callers 15

index.test.tsFile · 0.90
devStartAndExportFunction · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90
index.test.tsFile · 0.90

Calls 5

closeMethod · 0.65
promisifyFunction · 0.50
forEachMethod · 0.45
destroyMethod · 0.45
applyMethod · 0.45

Tested by 1

devStartAndExportFunction · 0.72