From 9adf99d9bf59c70f1c06d1d621e11925d2261ebd Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Tue, 3 Feb 2026 11:44:58 +0100 Subject: [PATCH] BOX_MODEL_TIMEOUT_MS timeout --- playwriter/src/aria-snapshot.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/playwriter/src/aria-snapshot.ts b/playwriter/src/aria-snapshot.ts index eadd979..e578a7c 100644 --- a/playwriter/src/aria-snapshot.ts +++ b/playwriter/src/aria-snapshot.ts @@ -161,6 +161,7 @@ const LABEL_ROLES = new Set([ ]) const MAX_LABEL_POSITION_CONCURRENCY = 24 +const BOX_MODEL_TIMEOUT_MS = 5000 const CONTEXT_ROLES = new Set([ 'navigation', @@ -931,7 +932,16 @@ async function getLabelBoxesForRefs({ } await sema.acquire() try { - const response = await session.send('DOM.getBoxModel', { backendNodeId: ref.backendNodeId }) as Protocol.DOM.GetBoxModelResponse + const response = await Promise.race([ + session.send('DOM.getBoxModel', { backendNodeId: ref.backendNodeId }) as Promise, + new Promise((resolve) => { + setTimeout(() => { resolve(null) }, BOX_MODEL_TIMEOUT_MS) + }), + ]) + if (!response) { + logger?.error?.('[playwriter] getBoxModel timed out for', ref.ref) + return null + } const box = buildBoxFromQuad(response.model.border) if (!box) { return null