mirror of https://github.com/garrytan/gstack.git
* fix(browse): route 4 lifecycle handlers through activeBrowserManager indirection Module-level idleCheckTick, parent watchdog, SIGTERM handler, and buildFetchHandler's onDisconnect wire all read the module-level BrowserManager directly. For embedders (gbrowser) that pass their own instance into buildFetchHandler, the module-level instance never has launchHeaded() called on it — connectionMode stays 'launched' forever, headed-mode early-returns never fire, and after 30 min of HTTP idle the server self-terminates out from under the overlay. Adds `let activeBrowserManager: BrowserManager` at module scope (symmetric with the existing `let activeShutdown` pattern). buildFetchHandler retargets it at cfg.browserManager and CHAINS cfg.browserManager.onDisconnect to activeShutdown, preserving any caller-installed handler instead of clobbering it. Six edit sites in browse/src/server.ts: - Edit 1 (~705): declare activeBrowserManager - Edit 2 (~596): extract idleCheckTick + __testInternals__ export - Edit 3 (~658): parent watchdog reads activeBrowserManager - Edit 4 (~1387): retarget + chain cfgBrowserManager.onDisconnect - Edit 5 (verify): line 714 default stays in place - Edit 6 (~1212): SIGTERM handler reads activeBrowserManager * test(browse): pin idle timer + onDisconnect dual-instance fix behaviorally Adds 5 behavioral tests to browse/test/server-factory.test.ts under a new 'idle timer + onDisconnect dual-instance fix' describe block: - T1 (CRITICAL — REGRESSION): headed embedder does not auto-shutdown at idle. Pins the bug this PR fixes. - T2 (paired defensive): headless still auto-shuts down at idle. Catches a future refactor that breaks the inverse case. - T3 (chain semantics): buildFetchHandler chains cfgBrowserManager.onDisconnect, preserving any caller-set handler. Uses .rejects.toThrow for the async shutdown path. - T4 (tunnelActive): tunnel-active blocks idle-shutdown even in headless mode. - T5 (static guard): exactly 3 module-level lifecycle sites use activeBrowserManager.getConnectionMode() — idleCheckTick, parent watchdog, SIGTERM. Catches refactor-introduced regressions before CI. Reuses existing makeMinimalConfig() + __resetRegistry() patterns from the factory contract tests. New makeMockBrowserManager() helper. beforeEach also resets module state via setTunnelActive, setLastActivity, and resetShutdownState from __testInternals__. Also deletes the old 'idle check skips in headed mode' string-grep test from browse/test/sidebar-ux.test.ts at line 1596. That test would have passed even with the dual-instance bug present (grepped for "=== 'headed'" + 'return' in the same window). Behavioral coverage moved to server-factory.test.ts. Verified: 33/33 tests pass in browse/test/server-factory.test.ts. * chore: bump version and changelog (v1.43.3.0) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| activity.ts | ||
| audit.ts | ||
| browse-client.ts | ||
| browser-manager.ts | ||
| browser-skill-commands.ts | ||
| browser-skill-write.ts | ||
| browser-skills.ts | ||
| buffers.ts | ||
| bun-polyfill.cjs | ||
| cdp-allowlist.ts | ||
| cdp-bridge.ts | ||
| cdp-commands.ts | ||
| cdp-inspector.ts | ||
| claude-bin.ts | ||
| cli.ts | ||
| commands.ts | ||
| config.ts | ||
| content-security.ts | ||
| cookie-import-browser.ts | ||
| cookie-picker-routes.ts | ||
| cookie-picker-ui.ts | ||
| domain-skill-commands.ts | ||
| domain-skills.ts | ||
| error-handling.ts | ||
| file-permissions.ts | ||
| find-browse.ts | ||
| find-security-sidecar.ts | ||
| media-extract.ts | ||
| meta-commands.ts | ||
| network-capture.ts | ||
| path-security.ts | ||
| platform.ts | ||
| project-slug.ts | ||
| proxy-config.ts | ||
| proxy-redact.ts | ||
| pty-session-cookie.ts | ||
| read-commands.ts | ||
| sanitize.ts | ||
| screenshot-size-guard.ts | ||
| security-bunnative.ts | ||
| security-classifier.ts | ||
| security-sidecar-client.ts | ||
| security-sidecar-entry.ts | ||
| security.ts | ||
| server.ts | ||
| sidebar-utils.ts | ||
| skill-token.ts | ||
| snapshot.ts | ||
| socks-bridge.ts | ||
| sse-session-cookie.ts | ||
| stealth.ts | ||
| tab-session.ts | ||
| telemetry.ts | ||
| terminal-agent.ts | ||
| token-registry.ts | ||
| tunnel-denial-log.ts | ||
| url-validation.ts | ||
| welcome.html | ||
| write-commands.ts | ||
| xvfb.ts | ||