fix(engine): suppress font-loading 404 noise in render console output (#195)

* fix(engine): suppress font-loading 404 noise in render console output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(engine): downgrade resource 404s to buffer-only instead of suppressing

Address review feedback: instead of silently dropping "Failed to load
resource" errors (which could hide real asset failures), keep them in
browserConsoleBuffer for diagnostics but don't print to stdout. Real
asset 404s are still caught by the file server's own logging.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(engine): narrow 404 filter to font CDN domains and woff2 files only

Address review: filter was too broad and could suppress real asset
failures. Now only suppresses 404s matching fonts.googleapis,
fonts.gstatic, or .woff2 file extensions. Missing images, scripts,
and videos will still surface as [Browser:ERROR] in render output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Miguel Ángel
2026-04-02 14:30:35 -07:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 7f4e4333e5
commit 38aadc2a25
+13 -1
View File
@@ -149,9 +149,21 @@ export async function initializeSession(session: CaptureSession): Promise<void>
page.on("console", (msg: ConsoleMessage) => {
const type = msg.type();
const text = msg.text();
// Suppress font-loading 404s only. These are expected when deterministic
// font injection replaces Google Fonts @import URLs with embedded base64.
// Narrowed to font CDN domains and font file extensions to avoid hiding
// real asset failures (images, scripts, videos).
const isFontLoadError =
type === "error" &&
text.startsWith("Failed to load resource") &&
/fonts\.googleapis|fonts\.gstatic|\.woff2?(\b|$)/i.test(text);
const prefix =
type === "error" ? "[Browser:ERROR]" : type === "warn" ? "[Browser:WARN]" : "[Browser]";
console.log(`${prefix} ${text}`);
if (!isFontLoadError) {
console.log(`${prefix} ${text}`);
}
session.browserConsoleBuffer.push(`${prefix} ${text}`);
if (session.browserConsoleBuffer.length > BROWSER_CONSOLE_BUFFER_SIZE) {