MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / close

Function close

packages/cli/src/auth/loopback.ts:76–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

74
75 let closed = false;
76 const close = async (): Promise<void> => {
77 if (closed) return;
78 closed = true;
79 clearTimeout(timer);
80 // `server.close()` only refuses NEW connections — it does NOT
81 // terminate existing keep-alive sockets, which browsers default to
82 // and idle for minutes (Chrome ~5min). Without `closeAllConnections`
83 // the CLI process hangs after "Signed in" until the browser closes
84 // its idle socket. `respond()` also emits `Connection: close` so the
85 // browser doesn't try to keep-alive in the first place.
86 server.closeAllConnections?.();
87 await new Promise<void>((resolve) => server.close(() => resolve()));
88 };
89
90 const timer = setTimeout(() => {
91 rejectResult(new Error(`OAuth callback timed out after ${timeoutMs}ms`));

Callers 1

startLoopbackFunction · 0.70

Calls 2

resolveFunction · 0.85
closeMethod · 0.65

Tested by

no test coverage detected