Abort http_client _before_ destroying context

XHR, for example, needs the context to properly shutdown. It get the page via
exec.context.page. Now, we could store the page on the XHR instance, sure. But
the point is the js.Context should never need the HttpClient, so it should
always be safe to abort inflight requests before canceling the context.

Fixes some flaky WPT crashes.
This commit is contained in:
Karl Seguin
2026-05-06 18:42:06 +08:00
parent 0c87fd6771
commit 042df590a2

View File

@@ -405,6 +405,10 @@ pub fn deinit(self: *Frame) void {
}
const browser = page.session.browser;
// don't abort pending frames.
browser.http_client.abortFrame(self._frame_id, .{});
browser.env.destroyContext(self.js);
// Must be after context is destroyed. A finalizer can reach into the *Worker
@@ -415,9 +419,6 @@ pub fn deinit(self: *Frame) void {
self._script_manager.base.shutdown = true;
// don't abort pending frames.
browser.http_client.abortFrame(self._frame_id, .{});
self._script_manager.deinit();
self._style_manager.deinit();