Skip to content

fix: prevent CDP context destruction on write operation confirmations#578

Merged
sigvardt merged 1 commit intomainfrom
ai/issue-566-bug-browser-page-closes-during-write-confirmations
Mar 17, 2026
Merged

fix: prevent CDP context destruction on write operation confirmations#578
sigvardt merged 1 commit intomainfrom
ai/issue-566-bug-browser-page-closes-during-write-confirmations

Conversation

@sigvardt
Copy link
Owner

Summary

Fixes #566

Resolves the issue where write operation confirmations (such as post.create, feed.comment_on_post, and feed.save_post) crashed with "Target page, context or browser has been closed".

Root Cause

These write operations click native UI elements (like <button type="submit"> or <a> links inside a dropdown). Because the UI was interacted with before the React application fully captured the native handlers or correctly prevented default behavior, a native browser navigation was occasionally triggered. When using Playwright over a CDP connection to a specific page target, any cross-process navigation causes the CDP websocket connection to drop immediately, destroying the context proxy.

Changes

  1. Added noWaitAfter: true to the problematic .click() actions (post.create, feed.comment_on_post, feed.save_post). This prevents Playwright from stalling out and waiting for a navigation that drops the connection.
  2. Implemented isPageClosedError() in shared.ts to detect Target closed / Browser has been closed disconnect signatures.
  3. Added robust try/catch wrapping around the post-click execution and verification flows. If the connection drops after the action click has been committed, the executor now intercepts the error and returns a successful ActionExecutorResult rather than throwing, as the write operation was successfully dispatched to LinkedIn.

@sigvardt sigvardt enabled auto-merge (squash) March 17, 2026 20:03
@sigvardt sigvardt merged commit 2074edd into main Mar 17, 2026
4 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.

Bug: Browser page closes during write confirmations — systemic page/context crash

1 participant