Skip to content

chore: port errors, connection, events and waiter from the Node.js client - #2055

Merged
Yury Semikhatsky (yury-s) merged 14 commits into
microsoft:mainfrom
yury-s:rewrite-core-waiter
Nov 18, 2026
Merged

Yury Semikhatsky (yury-s) merged 14 commits into
microsoft:mainfrom
yury-s:rewrite-core-waiter

Conversation

@yury-s

Copy link
Copy Markdown
Member

Summary

  • Errors, Connection, ChannelOwner, Events, EventEmitter, TimeoutSettings and Waiter now follow errors.ts, connection.ts, channelOwner.ts, events.ts, eventEmitter.ts, timeoutSettings.ts and waiter.ts; // java: comments mark the Java-specific spots.
  • All waitFor* methods go through Waiter, and events are emitted under the upstream event names.
  • Behaviour changes: a wait timeout names the event it waited for, "Page crashed" is a plain PlaywrightException, and a navigation error fails the wait regardless of the URL matcher. Five java: fixmes in the ported tests are dropped.

@yury-s

Copy link
Copy Markdown
Member Author

One issue worth fixing here; the rest of the port looks sound.

ChannelOwner.updateSubscription throws once the connection is closed, and that masks the real wait error.

  • Upstream swallows the failure: updateSubscription(...).catch(() => {}) in channelOwner.ts. Here it goes through sendMessageAsync, which throws synchronously when closedError is set.
  • WaitableEvent.dispose() calls off(), and it runs in the finally of WaitableRace.get(). For events with a subscription (request, response, console, dialog, filechooser) the exception from dispose replaces the waiter's own error.
  • Checked on a remote connection, closing the browser with setReason("custom reason") inside the callback:
    • page.waitForPopup → TargetClosedError: custom reason (correct)
    • page.waitForRequest → TargetClosedError: Browser has been closed (reason lost)
  • BT-059 passes partly by accident: the request waiter gets its "Target page, context or browser has been closed" message from this masking exception, not from the waiter's close rejection.
  • page.offRequest(...) / page.onRequest(...) after a disconnect throw TargetClosedError; upstream is silent.

Not a regression (on main the same path threw from JsonPipe.send), but since this PR ports channelOwner.ts and routes every wait through it, the fix belongs here: catch and ignore the exception in updateSubscription.

CI: the only red job is dev (macos-26-xlarge, webkit), failing in TestProxy, which also fails on main on macOS.

A closed connection made off() throw from the dispose of a wait and replaced the error of the wait.
@yury-s

Copy link
Copy Markdown
Member Author

Fixed in f6d1847: ChannelOwner.updateSubscription now ignores a failed send, like .catch(() => {}) in channelOwner.ts. Added a test in TestBrowserTypeConnect that closes a remote browser with a reason inside page.waitForRequest and checks that the reason is in the error and that onRequest/offRequest do not throw after the disconnect.

On Firefox the pipe closes before the pages report their close, and the pump threw 'Browser closed' from the wait instead of the close error of the waiter.
connect() waited forever once the websocket was open. The three fixmes for it passed whenever the
websocket took longer than the timeout to open, which failed the run.
@yury-s
Yury Semikhatsky (yury-s) merged commit 8ffd0b5 into microsoft:main Nov 18, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants