case 4690 - report browser download/launch failures: logged at Error, specific error returned to the client
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -799,10 +799,18 @@ What could be the issue here?
|
||||
var FetcherOptions = new BrowserFetcherOptions();
|
||||
if (!string.IsNullOrWhiteSpace(ServerBootConfig.REPORT_RENDER_BROWSER_DOWNLOAD_PATH))
|
||||
FetcherOptions.Path = ServerBootConfig.REPORT_RENDER_BROWSER_DOWNLOAD_PATH;
|
||||
var InstalledBrowser = await new BrowserFetcher(FetcherOptions).DownloadAsync();
|
||||
//launch exactly what was downloaded, otherwise Puppeteer looks in its default folder beside the app
|
||||
lo.ExecutablePath = InstalledBrowser.GetExecutablePath();
|
||||
log.LogDebug($"Report browser: {lo.ExecutablePath}");
|
||||
try
|
||||
{
|
||||
var InstalledBrowser = await new BrowserFetcher(FetcherOptions).DownloadAsync();
|
||||
//launch exactly what was downloaded, otherwise Puppeteer looks in its default folder beside the app
|
||||
lo.ExecutablePath = InstalledBrowser.GetExecutablePath();
|
||||
log.LogDebug($"Report browser: {lo.ExecutablePath}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await HandleBrowserFailure(job, log, $"downloaded to \"{FetcherOptions.Path}\" (check internet access and that the folder is writable)", ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//Set Chromium args
|
||||
@@ -856,7 +864,17 @@ What could be the issue here?
|
||||
|
||||
//API DOCS http://www.puppeteersharp.com/api/index.html
|
||||
log.LogDebug($"Launching headless Browser and new page now:");
|
||||
using (var browser = await Puppeteer.LaunchAsync(lo))
|
||||
IBrowser launchedBrowser;
|
||||
try
|
||||
{
|
||||
launchedBrowser = await Puppeteer.LaunchAsync(lo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await HandleBrowserFailure(job, log, $"started from \"{lo.ExecutablePath}\" with arguments '{string.Join(" ", lo.Args)}' (on Linux check for missing libraries with ldd)", ex);
|
||||
return;
|
||||
}
|
||||
using (var browser = launchedBrowser)
|
||||
using (var page = (await browser.PagesAsync())[0])
|
||||
{
|
||||
//track this process for timeout purposes
|
||||
@@ -1271,6 +1289,20 @@ What could be the issue here?
|
||||
|
||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
|
||||
}
|
||||
|
||||
//Report browser could not be downloaded or started: log it properly and give the client a specific error
|
||||
//instead of the generic job failure it got when this escaped to the job processor
|
||||
static async Task HandleBrowserFailure(OpsJob job, ILogger log, string what, Exception ex)
|
||||
{
|
||||
var msg = $"Report rendering browser could not be {what}: {ExceptionUtil.ExtractAllExceptionMessages(ex)}";
|
||||
log.LogError(ex, msg);
|
||||
var json = Newtonsoft.Json.JsonConvert.SerializeObject(
|
||||
new { rendererror = new { exception = msg } },
|
||||
Newtonsoft.Json.Formatting.None
|
||||
);
|
||||
await JobsBiz.LogJobAsync(job.GId, json);
|
||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Failed);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CancelJob(Guid jobId)
|
||||
|
||||
Reference in New Issue
Block a user