Skip to content

fix: do not hang API calls after a page crash#41327

Open
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:fix-31907
Open

fix: do not hang API calls after a page crash#41327
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:fix-31907

Conversation

@dgozman

@dgozman dgozman commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Reject pending protocol calls when the page crashes (Chromium/Firefox), like we already do on close, so in-flight actions and assertions fail fast instead of hanging.
  • Unify the page crash/close lifecycle and let page.close() work after a crash.

Fixes #31907

Reject pending protocol calls when the page crashes (Chromium/Firefox), the
same way we already do on close, so in-flight actions and assertions fail fast
instead of hanging. Unify the page crash/close lifecycle and allow
page.close() to work after a crash.

Fixes: microsoft#31907
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7341 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

1 failed
❌ [firefox-page] › page/workers.spec.ts:40 › should emit created and destroyed events @firefox-ubuntu-22.04-node20

3 flaky ⚠️ [chromium-page] › page/workers.spec.ts:191 › should attribute network activity for worker inside iframe to the iframe `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/video.spec.ts:476 › screencast › should capture static page in persistent context @smoke `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`

39617 passed, 749 skipped


Merge workflow run.

return this.sendEvenAfterCrash(method, params);
}

async sendEvenAfterCrash<T extends keyof Protocol.CommandParameters>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this name is confusing, is the intent to be able to send closePage even after the page has crashed?

// The page content target is gone (e.g. after a crash) and the orphaned page
// proxy cannot be destroyed via the protocol. Finalize the close locally so
// page.close() resolves and the page is reported closed.
// TODO: the proper fix is in the browser - destroy the orphaned page proxy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's implement it in this change?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a browser side change. We can wait with landing this PR until the browser is fixed though.

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]: Playwright hangs when doing element assertions when the webpage crashes with out of memory

2 participants