use inspector.resetContextGroup during cdp deinit

Ensure the inspector is correctly reset from context before deinit it.
It fixes the contextCollected crash in a better way.
This commit is contained in:
Pierre Tachoire
2026-01-27 17:01:55 +01:00
parent 9d8e5263a6
commit 68fbc0bde3
3 changed files with 17 additions and 7 deletions

View File

@@ -424,6 +424,11 @@ pub fn BrowserContext(comptime CDP_T: type) type {
// in progress before deinit.
self.cdp.browser.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.
self.inspector.resetContextGroup();
self.session.browser.runMessageLoop();
self.inspector.deinit();
// abort all intercepted requests before closing the sesion/page