From b16ce08da7e62da39437b488d4ca79896a9378b3 Mon Sep 17 00:00:00 2001 From: Julien Neuhart Date: Tue, 8 Sep 2026 18:35:03 +0200 Subject: [PATCH] perf(chromium): skip formatting a discarded debug message per response --- pkg/modules/chromium/events.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/modules/chromium/events.go b/pkg/modules/chromium/events.go index ba2a7305..52e7b2a2 100644 --- a/pkg/modules/chromium/events.go +++ b/pkg/modules/chromium/events.go @@ -323,7 +323,15 @@ func listenForEventResponseReceived( return } - logger.DebugContext(ctx, fmt.Sprintf("event EventResponseReceived fired for a resource: %+v", ev.Response)) + // Formatting the whole response is the most expensive thing this + // listener does, and it runs per sub-resource on chromedp's single + // per-target event goroutine while that goroutine holds the mutex + // it also takes to dispatch command responses. At the default log + // level the result is discarded, so gate it on the level rather + // than let slog drop it after the fact. + if logger.Enabled(ctx, slog.LevelDebug) { + logger.DebugContext(ctx, fmt.Sprintf("event EventResponseReceived fired for a resource: %+v", ev.Response)) + } if slices.Contains(options.failOnResourceOnHttpStatusCode, ev.Response.Status) { if !shouldCheckResourceHttpStatusCode(ev.Response.URL, normalizedIgnoreDomains) {