You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent hanging in Playwright acceptance tests with terminal error handling
- Add terminal error detection for ERR_ABORTED and frame detachment errors
- Prevent infinite retries for unrecoverable navigation failures
- Improve screenshot plugin error handling with browser state checks
- Reduce screenshot timeout from 30s to 5s for faster failure
- Add terminal error handling in recorder to immediately re-throw fatal errors
- Enhance retryFailedStep plugin to skip terminal navigation errors
Fixes hanging issues in Playwright acceptance tests when frames are detached
or browser connections are lost during iframe/within operations.
Copy file name to clipboardExpand all lines: lib/helper/Playwright.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1026,7 +1026,18 @@ class Playwright extends Helper {
1026
1026
thrownewError(`Page is not initialized after auto-initialization. this.page=${this.page}, this.isRunning=${this.isRunning}, this.browser=${!!this.browser}, this.browserContext=${!!this.browserContext}`)
// Handle terminal navigation errors that shouldn't be retried
1033
+
if(err.message&&(err.message.includes('ERR_ABORTED')||err.message.includes('frame was detached')||err.message.includes('Target page, context or browser has been closed'))){
1034
+
// Mark this as a terminal error to prevent retries
// Don't retry navigation errors that are known to be terminal
94
+
if(err&&err.message&&(err.message.includes('ERR_ABORTED')||err.message.includes('frame was detached')||err.message.includes('Target page, context or browser has been closed')))returnfalse
@@ -184,8 +192,19 @@ export default function (config) {
184
192
if(!quietMode){
185
193
output.plugin('screenshotOnFail',`Failed to save screenshot: ${err.message}`)
186
194
}
187
-
if(err&&err.type&&err.type==='RuntimeError'&&err.message&&(err.message.indexOf('was terminated due to')>-1||err.message.indexOf('no such window: target window already closed')>-1)){
188
-
output.log(`Can't make screenshot, ${err}`)
195
+
// Enhanced error handling for browser closed scenarios
196
+
if(
197
+
err&&
198
+
((err.message&&
199
+
(err.message.includes('Target page, context or browser has been closed')||
200
+
err.message.includes('Browser page has been closed')||
201
+
err.message.includes('Browser has been disconnected')||
202
+
err.message.includes('was terminated due to')||
203
+
err.message.includes('no such window: target window already closed')||
if(err&&(err.isTerminal||(err.message&&(err.message.includes('ERR_ABORTED')||err.message.includes('frame was detached')||err.message.includes('Target page, context or browser has been closed'))))){
0 commit comments