Skip to content

Commit

Permalink
fix: warn on PDF timeout (#9586)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih authored Jan 6, 2024
1 parent 305cabf commit 28b1ab1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Docfx.App/PdfBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,16 @@ IResult TocPage(string url)
if (response is null || !response.Ok)
throw new InvalidOperationException($"Failed to build PDF page [{response?.Status}]: {url}");

await page.AddScriptTagAsync(new() { Content = EnsureHeadingAnchorScript });
await page.WaitForFunctionAsync("!window.docfx || window.docfx.ready");
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
try
{
await page.AddScriptTagAsync(new() { Content = EnsureHeadingAnchorScript });
await page.WaitForFunctionAsync("!window.docfx || window.docfx.ready");
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
}
catch (TimeoutException)
{
Logger.LogWarning($"Timeout waiting for page to load, generated PDF page may be incomplete: {url}");
}

return await page.PdfAsync();
}
Expand Down

0 comments on commit 28b1ab1

Please sign in to comment.