Skip to content

Commit b459078

Browse files
fix(server): click timeouts with no remaining match no longer rule out the click
A target can vanish because the click removed it or navigated, so the zero-match message now warns to check the page before retrying. The named-target wrapper also keeps Playwright's TimeoutError as its cause. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f392d54 commit b459078

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ it.effect("names the click target that matched nothing when the server browser t
332332
error: {
333333
_tag: "PreviewAutomationTimeoutError",
334334
message:
335-
'No element matches ".definitely-no-such-t3-target" after the timeout. Take a fresh snapshot and use its locator.',
335+
'No element matches ".definitely-no-such-t3-target" after the timeout. The click may have happened and removed its target or navigated; check the page before retrying, then take a fresh snapshot and use its locator.',
336336
},
337337
}),
338338
).pipe(Effect.forkScoped);

‎apps/server/src/preview/ServerBrowserPage.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ describe("server browser element refs", () => {
109109
const absent = await failure(".definitely-no-such-t3-target");
110110
expect(absent.tag).toBe("PreviewAutomationTimeoutError");
111111
expect(absent.message).toBe(
112-
'No element matches ".definitely-no-such-t3-target" after the timeout. Take a fresh snapshot and use its locator.',
112+
'No element matches ".definitely-no-such-t3-target" after the timeout. The click may have happened and removed its target or navigated; check the page before retrying, then take a fresh snapshot and use its locator.',
113113
);
114+
expect(absent.cause).toMatchObject({ name: "TimeoutError" });
114115
const hidden = await failure("button");
115116
expect(hidden.tag).toBe("PreviewAutomationTimeoutError");
116117
expect(hidden.message).toBe(

‎apps/server/src/preview/ServerBrowserPage.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export class ServerBrowserOperationError extends Error {
3232
readonly tag: string;
3333
readonly detail: unknown;
3434

35-
constructor(tag: string, message: string, detail?: unknown) {
36-
super(message);
35+
constructor(tag: string, message: string, detail?: unknown, options?: ErrorOptions) {
36+
super(message, options);
3737
this.tag = tag;
3838
this.detail = detail;
3939
}
@@ -683,8 +683,10 @@ const namedTargetTimeout = async (
683683
return new ServerBrowserOperationError(
684684
"PreviewAutomationTimeoutError",
685685
matches === 0
686-
? `No element matches ${target} after the timeout. Take a fresh snapshot and use its locator.`
686+
? `No element matches ${target} after the timeout. The click may have happened and removed its target or navigated; check the page before retrying, then take a fresh snapshot and use its locator.`
687687
: `${target} still matches an element after the timeout. The click may have happened; check the page before retrying.`,
688+
undefined,
689+
{ cause },
688690
);
689691
};
690692

0 commit comments

Comments
 (0)