MCPcopy Create free account
hub / github.com/firebase/firebase-tools / createDestroyer

Function createDestroyer

src/utils.ts:524–546  ·  view source on GitHub ↗
(server: http.Server)

Source from the content-addressed store, hash-verified

522 * @return a function that destroys all connections and closes the server
523 */
524export function createDestroyer(server: http.Server): () => Promise<void> {
525 const connections = new Set<Socket>();
526
527 server.on("connection", (conn) => {
528 connections.add(conn);
529 conn.once("close", () => connections.delete(conn));
530 });
531
532 // Make calling destroyer again just noop but return the same promise.
533 let destroyPromise: Promise<void> | undefined = undefined;
534 return function destroyer() {
535 if (!destroyPromise) {
536 destroyPromise = new Promise((resolve, reject) => {
537 server.close((err) => {
538 if (err) return reject(err);
539 resolve();
540 });
541 connections.forEach((socket) => socket.destroy());
542 });
543 }
544 return destroyPromise;
545 };
546}
547
548/**
549 * Returns the given date formatted as `YYYY-mm-dd HH:mm:ss`.

Callers 4

startServerFunction · 0.90
startMethod · 0.90
startMethod · 0.90
startMethod · 0.90

Calls 6

resolveFunction · 0.85
onMethod · 0.80
closeMethod · 0.80
rejectFunction · 0.70
addMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…