Skip to content

Commit 176a040

Browse files
fix(server): a timed-out preview request no longer evicts the shared server browser
A foreground preview request that got no reply within its budget made the broker disconnect its host. The server browser is one in-process host shared by every thread, so that failed other threads' in-flight calls and left new calls with no host until it re-registered. Timeouts now fail only the request for the server browser; desktop hosts are still evicted so a dead connection can recover. The repro test now passes `preferred` through the connect options, as ServerBrowser does. Fixes #16921 AI-assisted; verified with the tests and tools listed above.
1 parent 708fbef commit 176a040

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/server/src/mcp/PreviewAutomationBroker.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ it.effect("keeps the server browser host for other threads when one request time
388388
},
389389
};
390390
const openDelivered = yield* Deferred.make<RoutedRequest>();
391-
const requests = requestsFrom(yield* broker.connect(makeHost({ clientId, preferred: true })));
391+
const requests = requestsFrom(
392+
yield* broker.connect(makeHost({ clientId }), { preferred: true }),
393+
);
392394
yield* Stream.runForEach(requests, (request) => {
393395
if (request.operation === "open") return Deferred.succeed(openDelivered, request);
394396
if (request.operation === "snapshot") return Effect.void;

‎apps/server/src/mcp/PreviewAutomationBroker.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,11 @@ export const make = Effect.gen(function* PreviewAutomationBrokerMake() {
662662
// The enclosing operation owns the span for this inline handler.
663663
onNone: Effect.fnUntraced(function* () {
664664
// Never replay possibly applied actions; slow metadata reads must not evict the host.
665-
if (input.updateCurrentTab !== false) {
665+
// The in-process server browser is shared by every thread, so one stall must not evict it.
666+
if (
667+
input.updateCurrentTab !== false &&
668+
connection.clientId !== SERVER_BROWSER_AUTOMATION_CLIENT_ID
669+
) {
666670
yield* disconnect(connection.clientId, connection.queue, true);
667671
}
668672
return yield* new PreviewAutomationTimeoutError(requestContext);

0 commit comments

Comments
 (0)