Page.Dispose() never completes
See original GitHub issueUsing 0.3.2, if you try to dispose of a Page instance, it awaits forever. Try this, the last Console.WriteLine() call is never reached because it all hangs when the inner using statement calls Dispose on the page instance.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using PuppeteerSharp;
namespace PuppeteerSharpPdfDemo
{
class MainClass
{
public static void Main(string[] args)
{
MainAsync().GetAwaiter().GetResult();
}
public static async Task MainAsync()
{
var options = new LaunchOptions
{
Headless = true
};
Console.WriteLine("Downloading chromium");
await Downloader.CreateDefault().DownloadRevisionAsync(Downloader.DefaultRevision);
Console.WriteLine("Navigating google");
using (var browser = await Puppeteer.LaunchAsync(options, Downloader.DefaultRevision))
using (var page = await browser.NewPageAsync())
{
await page.GoToAsync("http://www.google.com");
Console.WriteLine("Generating PDF");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"));
Console.WriteLine("Export completed");
//Console.ReadLine();
}
Console.WriteLine("The End"); // this line never reached :(
}
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Page.Dispose() never completes · Issue #122
Using 0.3.2, if you try to dispose of a Page instance, it awaits forever. Try this, the last Console.WriteLine() call is never reached ......
Read more >What happens to Tasks that are never completed? Are they ...
However, let's say SetResult(..) is never called, and someClassInstance stops being referenced and is garbage collected. Does this create a ...
Read more >Implement a DisposeAsync method
The DisposeAsync() returns a ValueTask that represents the asynchronous disposal operation. It's typical when implementing the IAsyncDisposable ...
Read more >autoDispose
autoDispose. A common use case is to destroy the state of a provider when it is no-longer used. There are multiple reasons for...
Read more >Shared Context between Tests
For context cleanup, add the IDisposable interface to your test class, and put the cleanup code in the Dispose() method. Here is a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay that works!
It’s something we need to work on, of course. I’m glad you got it running!
(don’t close this issue)