MCPcopy Index your code
hub / github.com/garrytan/gstack / idleCheckTick

Function idleCheckTick

browse/src/server.ts:636–648  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

634// server-factory.test.ts call this directly so the idle-shutdown path can be
635// exercised without waiting 60s for the interval to fire.
636function idleCheckTick() {
637 // Headed mode: the user is looking at the browser. Never auto-die.
638 // Only shut down when the user explicitly disconnects or closes the window.
639 // Reads via the activeBrowserManager indirection so embedders that pass
640 // their own BrowserManager into buildFetchHandler hit the right instance.
641 if (activeBrowserManager.getConnectionMode() === 'headed') return;
642 // Tunnel mode: remote agents may send commands sporadically. Never auto-die.
643 if (tunnelActive) return;
644 if (Date.now() - lastActivity > IDLE_TIMEOUT_MS) {
645 console.log(`[browse] Idle for ${IDLE_TIMEOUT_MS / 1000}s, shutting down`);
646 activeShutdown?.();
647 }
648}
649const idleCheckInterval = setInterval(idleCheckTick, 60_000);
650
651// Test-only surface for server-factory.test.ts. Lets the dual-instance

Callers

nothing calls this directly

Calls 2

activeShutdownFunction · 0.85
getConnectionModeMethod · 0.80

Tested by

no test coverage detected