Merge pull request #1651 from lightpanda-io/more_pump_message_loop

Run the MessageLoop [a lot] more.
This commit is contained in:
Karl Seguin
2026-02-26 11:35:11 +08:00
committed by GitHub
11 changed files with 73 additions and 25 deletions

View File

@@ -436,17 +436,18 @@ pub fn BrowserContext(comptime CDP_T: type) type {
pub fn deinit(self: *Self) void {
const browser = &self.cdp.browser;
const env = &browser.env;
// Drain microtasks makes sure we don't have inspector's callback
// in progress before deinit.
browser.env.runMicrotasks();
env.runMicrotasks();
// resetContextGroup detach the inspector from all contexts.
// It append async tasks, so we make sure we run the message loop
// before deinit it.
browser.env.inspector.?.resetContextGroup();
browser.runMessageLoop();
browser.env.inspector.?.stopSession();
env.inspector.?.resetContextGroup();
_ = env.pumpMessageLoop();
env.inspector.?.stopSession();
// abort all intercepted requests before closing the sesion/page
// since some of these might callback into the page/scriptmanager