case 4690 - PuppeteerSharp 25.15.0; launch arguments as separate elements; --lang keeps the server locale as browser default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-22 18:12:49 -07:00
parent 91f59d8554
commit f3e8026501
3 changed files with 29 additions and 11 deletions

View File

@@ -51,7 +51,7 @@
<PackageReference Include="NLog" Version="6.2.2" />
<PackageReference Include="NLog.Web.AspNetCore" Version="6.2.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.3" />
<PackageReference Include="PuppeteerSharp" Version="17.0.0" />
<PackageReference Include="PuppeteerSharp" Version="25.15.0" />
<PackageReference Include="QRCoder" Version="1.5.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.3.1" />

View File

@@ -809,25 +809,41 @@ What could be the issue here?
//Keep for debugging headfully
// var DefaultArgs = "--no-sandbox";
var DefaultArgs = "--headless --no-sandbox "; // --ignore-certificate-errors (potential proposal, not implemented yet for case 4632 saving here in case want to try it)
//PuppeteerSharp 25: each argument must be its own array element, a single "--a --b" string is passed to the browser as one unknown switch
//--headless is not needed here, LaunchOptions.Headless already adds it
var DefaultArgs = new[] { "--no-sandbox" }; // --ignore-certificate-errors (potential proposal, not implemented yet for case 4632 saving here in case want to try it)
if (!string.IsNullOrWhiteSpace(ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PARAMS))
{
log.LogDebug(
$"AYANOVA_REPORT_RENDER_BROWSER_PARAMS will be used: {ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PARAMS}"
);
lo.Args = new string[]
{
$"{ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PARAMS}",
}; // AYANOVA_REPORT_RENDER_BROWSER_PARAMS
//customer setting is one space separated string, split it into separate arguments
lo.Args = ServerBootConfig.AYANOVA_REPORT_RENDER_BROWSER_PARAMS.Split(
(char[])null,
StringSplitOptions.RemoveEmptyEntries
); // AYANOVA_REPORT_RENDER_BROWSER_PARAMS
}
else
{
log.LogDebug(
$"AYANOVA_REPORT_RENDER_BROWSER_PARAMS not set, using defaults '{DefaultArgs}'"
$"AYANOVA_REPORT_RENDER_BROWSER_PARAMS not set, using defaults '{string.Join(" ", DefaultArgs)}'"
);
lo.Args = new string[] { DefaultArgs };
lo.Args = DefaultArgs;
}
//Browser default locale follows the server OS, as it did before PuppeteerSharp 25 (old headless mode took it from the OS,
//current Chrome headless always defaults to en-US). Matters to report scripts that format without a locale, e.g. toLocaleDateString()
//A --lang in AYANOVA_REPORT_RENDER_BROWSER_PARAMS wins
var ServerLanguage = System.Globalization.CultureInfo.CurrentCulture.Name;
if (
!string.IsNullOrWhiteSpace(ServerLanguage)
&& !lo.Args.Any(z => z.StartsWith("--lang", StringComparison.OrdinalIgnoreCase))
)
{
lo.Args = lo.Args.Append($"--lang={ServerLanguage}").ToArray();
}
log.LogDebug($"Report browser launch arguments: '{string.Join(" ", lo.Args)}'");
System.Text.StringBuilder PageLog = new System.Text.StringBuilder();
if (!ReportRenderManager.KeepGoing(job.GId))