Bug 303619

Summary: [BFCache][WebSocket] don't dispatch error if websocket is closed in pagehide
Product: WebKit Reporter: Przemyslaw Gorszkowski <pgorszkowski>
Component: New BugsAssignee: Przemyslaw Gorszkowski <pgorszkowski>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Przemyslaw Gorszkowski
Reported 2025-12-05 01:30:38 PST
In current implementation, when a page with open WebSocket is cached in bfCache (because of the navigation), the error event ("WebSocket is closed due to suspension.") is queued and dispatched when the page is loaded back from the bfCache. This is intentional behaviour, but before the page is put in bfCache, the 'pagehide' event is dispatched and the page can handle it. In 'pagehide' event listener, the page can close the WebSocket, so no error should be dispatched by the browser in this case. I have created a test for that o WPT: https://github.com/web-platform-tests/wpt/pull/56457. I am importing it to WebKit: https://bugs.webkit.org/show_bug.cgi?id=303534. Here I will provide a fix for that.
Attachments
Przemyslaw Gorszkowski
Comment 1 2025-12-05 06:59:07 PST
EWS
Comment 2 2025-12-07 23:26:23 PST
Committed 304082@main (4028de758439): <https://commits.webkit.org/304082@main> Reviewed commits have been landed. Closing PR #54922 and removing active labels.
Radar WebKit Bug Importer
Comment 3 2025-12-07 23:27:14 PST
Note You need to log in before you can comment on or make changes to this bug.