try returning first page when not in PLAYWRITER_AUTO_ENABLE

This commit is contained in:
Tommy D. Rossi
2026-02-03 15:36:50 +01:00
parent 01a6622d71
commit a3c874ac4c
+9
View File
@@ -782,6 +782,15 @@ export class PlaywrightExecutor {
}
if (!process.env.PLAYWRITER_AUTO_ENABLE) {
const waitTimeoutMs = Math.min(timeout, 1000)
const startTime = Date.now()
while (Date.now() - startTime < waitTimeoutMs) {
const availablePages = context.pages().filter((p) => !p.isClosed())
if (availablePages.length > 0) {
return availablePages[0]
}
await new Promise((resolve) => setTimeout(resolve, 100))
}
throw new Error(NO_PAGES_AVAILABLE_ERROR)
}