-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
* Ensure existing targets are attached to pages * cr * Update lib/PuppeteerSharp/Cdp/CdpPage.cs Co-authored-by: Jonas Nyrup <[email protected]> * Don't fail close on dispose * Don't close pages from a connection on Dispose * change some browser disconnection stuff * Update lib/PuppeteerSharp/Browser.cs * Update lib/PuppeteerSharp/Cdp/CdpBrowser.cs * Update lib/PuppeteerSharp/Cdp/CdpBrowser.cs * Update lib/PuppeteerSharp/Cdp/CdpBrowser.cs * Add empty line --------- Co-authored-by: Jonas Nyrup <[email protected]>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -750,7 +750,22 @@ public void Dispose() | |
/// <inheritdoc/> | ||
public async ValueTask DisposeAsync() | ||
{ | ||
await CloseAsync().ConfigureAwait(false); | ||
try | ||
{ | ||
// We don't want to close the page if we're connected to the browser using `Connect`. | ||
if (Browser.Launcher == null) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kblok
Author
Member
|
||
{ | ||
return; | ||
} | ||
|
||
await CloseAsync().ConfigureAwait(false); | ||
} | ||
catch | ||
{ | ||
// Closing on dispose might not be bulletproof. | ||
// If the user didn't close the page explicitly, we won't fail. | ||
} | ||
|
||
GC.SuppressFinalize(this); | ||
} | ||
|
||
|
This line actually caused us headaches. This seems like a backwards incompatible change :(
Previously, we were opening new pages, and then disposing (Closing them afterwards). This change caused those pages to stay open indefinitely. I'd recommend reverting this change, as it seems counterintuitive. (Dispose should always try to close the page)