BOX_MODEL_TIMEOUT_MS timeout

This commit is contained in:
Tommy D. Rossi
2026-02-03 11:44:58 +01:00
parent 3f2063f999
commit 9adf99d9bf
+11 -1
View File
@@ -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<Protocol.DOM.GetBoxModelResponse>,
new Promise<null>((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