Repository navigation
Commit f7e7858
committed
fix(server): preview_wait_for stops at its timeout when the page stops answering
ServerBrowserPage.waitFor compared its deadline only after every check in a
poll round had settled. The selector check awaits Playwright's
locator.count() and the text check awaits page.evaluate(); neither takes a
timeout. When one stalls (a desktop-drawn tab whose Playwright utility world
never answers, a busy main thread, or a dialog opening mid-wait) the wait
never ends. It then holds the tab's SessionControl queue forever, so every
later action on that tab times out at the broker, and each broker timeout
disconnects the shared server-browser host for every thread.
The wait now arms one expiry timer per call, after the target locator is
resolved, and races both the poll's checks and the poll sleep against it.
The timer is cleared in finally on every path. This is the same expiry
shape evaluate and snapshot already use in this module. Racing each inner
await, rather than wrapping the whole loop, means the loop itself stops at
the deadline instead of polling CDP in the background. The error tag and
message are unchanged.
Behaviour change: the timeout is now a real deadline. Before, a wait always
finished one full round of checks before it could fail, so a very small
timeoutMs (such as 1 ms) can now fail on an element that is present if the
timer fires before the first CDP reply. evaluate already behaves this way.
Scope: this bounds a running wait. It does not cancel the stalled Playwright
read, which stays pending until it settles or the page closes. Budgets still
start when the run starts, so a wait queued more than about a second behind
another action on the same tab can still overrun the broker grace. The
type operation's focused-element probe has the same unbounded count() and
is left for a follow-up.
User story: When I ask an agent to wait for something in the Browser panel and the page stops answering, the wait gives up at its timeout and the agent can keep using the preview.1 parent cec8d73 commit f7e7858
2 files changed
Lines changed: 41 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
521 | 521 | | |
522 | 522 | | |
523 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
524 | 544 | | |
525 | 545 | | |
526 | 546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
947 | 947 | | |
948 | 948 | | |
949 | 949 | | |
950 | | - | |
951 | 950 | | |
952 | 951 | | |
953 | 952 | | |
| |||
962 | 961 | | |
963 | 962 | | |
964 | 963 | | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
973 | 983 | | |
974 | | - | |
| 984 | + | |
| 985 | + | |
975 | 986 | | |
976 | 987 | | |
977 | 988 | | |
| |||
0 commit comments