Skip to content

Environment browser: after a server restart, preview_status and preview_evaluate time out on tabs that existed before it #271

Backlog

Description

@immakermatty

After a T3 Code server restart, preview_status and preview_evaluate on an Environment browser tab opened before the restart end at the tool's 15 s limit ("Preview automation … timed out after 15000ms"). The page itself is alive and answers over DevTools at the same moment, so the hang is in T3 Code's connection to the Environment browser, not in the page.

What was observed

Seen on a hosted Personal Environment on 0.1.10-preview.20261127.1 (de55ba21), after the server restart of an update (t3 update, 2026-11-28 12:29:31Z).

  • t3_preview_list lists the thread's four tabs, with a new serverEpoch, revision 0 and navStatus Idle.
  • preview_status and preview_evaluate on one of them, a long-lived signed-in web app tab, time out after 15000 ms. This happened on three attempts between 13:01Z and 13:03Z, and on every call since. Before the restart (12:05Z) the same reads worked.
  • At 13:13Z, a raw DevTools client on 127.0.0.1:9222 (/json/list, then Runtime.evaluate on the target's webSocketDebuggerUrl) answered at once: visibility: "visible", wasDiscarded: false, readyState: "complete". The target still has the same id. The page is not frozen, not discarded and shows no dialog that blocks evaluation.
  • The Environment browser is a separate Chromium outside t3code.service. On another Environment it has run in its own scope since 2026-11-21 and survived two T3 restarts on 2026-11-28. Its pages and their sign-ins outlive a T3 restart, so the only new party after the restart is T3 Code's Playwright connection.

Not new in the preview build

apps/server/src/lazurio/environmentBrowserConnection.ts, environmentBrowserPage.ts and threadTabs.ts are identical between v0.1.10-lazurio.6 (7915fe9a) and de55ba21. environmentBrowser.ts changed only in preview_open/navigate (Lazurio account refusals, #265). The same is expected after any restart on .6.

Where it can hang (from the code, de55ba21)

  • environmentBrowser.ts keeps one shared connection for the server's lifetime (sharedBrowser). The connection is rebuilt only when it ends (connection.closed) or fails to connect. A connection that is up but no longer drives some pages is never replaced.
  • status → tabOf(targetId) → connection.tab(targetId) → findPage, which loops over context.pages() and awaits targetIdOf(page) for each one (context.newCDPSession(page) + Target.getTargetInfo). PAGE_ATTACH_TIMEOUT_MS bounds only the loop, not the awaits inside it. One page whose CDP session never resolves blocks findPage for every tab.
  • tab.state() → page.evaluate(...) has no timeout of its own. Its .catch covers a rejection, not a promise that never settles.
  • inTab (used by evaluate) goes through the same tabOf → findPage.

The tool then hits its 15 s limit, and the error does not say which step waited.

Proposal

  1. Bound each await in findPage (targetIdOf) and in tab.state(). On expiry, fail with an error that names the step, for example "the Environment browser connection did not attach page within N s".
  2. When a bounded step expires, drop the shared connection (browser = undefined) and disconnect it, so the next call connects again (connectOverCDP attaches to the existing pages again). Today only a new server restart does that.
  3. A test with a fake connection whose newCDPSession never resolves for one page: status on another tab still answers, and a second call reconnects.

Open questions for whoever takes this

  • Which await hangs (targetIdOf of some page, or page.evaluate on this one)? The server trace of the affected Environment (t3 trace, spans LazurioEnvironmentBrowser.status) can answer that. I have not read it.
  • Does a tab opened after the restart work in the same thread? If it hangs too, the whole shared connection is stuck. If it answers, only pages that existed before the connection was made are affected.

Workaround until then: read the page through DevTools directly (read-only Runtime.evaluate), or open a new tab. A new tab uses the same browser profile, so its site sign-ins stay.

Agent: environment a480495c-25e0-4e51-828b-1dbf1b77d62f · T3 thread mcp:57942b76-ee73-4e62-b152-1b92ea2a0812

Activity

  1. immakermatty commented on Nov 28, 2026

    @immakermatty
    Author

    Update after more data from the affected Environment (2026-11-28 13:15Z):

    • preview_status without tabId times out too, with the same broker message "Preview automation status timed out after 15000ms". t3_preview_list answers at once (4 tabs). So it is not one page. Every automation request of that thread hangs.
    • The message points at the host, not at a page. handleRequest in environmentBrowser.ts answers within its own budget (answerBudgetMs, 13.5 s for a 15 s request) with "The Environment browser did not finish … in … ms". The 15000 ms message is the broker's PreviewAutomationTimeoutError, so no host answered at all. Either the Environment browser host is not registered after the restart, or its requests never reach handleRequest. The unbounded findPage / page.evaluate waits from the issue text are still real, but they would show the host's message, not this one.
    • On another Environment the host comes back after a restart. Its server log (~/.t3/userdata/logs/boot-service.log) shows "T3's browser tools drive the Environment browser" 2–3 s after each of two restarts today (12:09:57 and 12:12:31), and lazurio browser link --json answers with its link.
    • Next check on the affected Environment: whether that log line appears after its restart (12:29:31Z), and what lazurio browser link --json answers. The host only registers while the Environment declares its browser (browserDeclaration, checked every 60 s, link check 10 s).

    Agent: environment a480495c-25e0-4e51-828b-1dbf1b77d62f · T3 thread mcp:57942b76-ee73-4e62-b152-1b92ea2a0812

  2. immakermatty commented on Nov 28, 2026

    @immakermatty
    Author

    Second update (2026-11-28 14:12Z), from the affected Environment:

    • The host did register after the restart. boot-service.log has "T3's browser tools drive the Environment browser" at 12:29:34.762, 3 s after the restart (12:29:31Z), and no later line. The host's stream therefore has not ended since: the loop logs that line again whenever it registers again.

    • lazurio browser link --json answers with its link (kind: browser-link). The declaration is in place.

    • So the host is registered and its stream is up, yet every automation request of the thread ends at the broker's 15 s limit, never at the host's own answer after 14 s (answerBudgetMs(15000) is 14000; the first update said 13.5 s, which was wrong). That leaves two places to look:

      1. Routing: the broker hands these requests to another client or connection than this host's (preferred: true registration, hostConnectionId).
      2. Delivery: the host's broker.respond does not reach the waiting request.

      A page that does not answer is ruled out: a raw DevTools client gets Runtime.evaluate answered on the same tab.

    • The server trace will not show it. On this build server.trace.ndjson records no LazurioEnvironmentBrowser.* spans; of the browser tools only PreviewAgentActivity.begin appears (checked on another Environment with a working preview_status). Whoever takes this needs a debug log around handleRequest/broker.respond, or a test that makes the broker route a request after a host re-registers under the same client id.

    Agent: environment a480495c-25e0-4e51-828b-1dbf1b77d62f · T3 thread mcp:57942b76-ee73-4e62-b152-1b92ea2a0812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions