Skip to content

Commit 9c50929

Browse files
committed
Fix process hanging after tests complete with Playwright
- Add delayed auto-exit (2s) after cleanup completes - Prevents Playwright event loops from keeping process alive - Can be disabled with CODECEPT_DISABLE_AUTO_EXIT env var - Uses unref() to allow natural exit if possible - Respects existing exit handlers and exit codes
1 parent 190ae7b commit 9c50929

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/helper/Playwright.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,18 @@ class Playwright extends Helper {
982982
}
983983
}
984984
}
985+
986+
// Schedule a delayed exit to prevent process hanging due to Playwright event loops
987+
// This ensures the process exits even if Playwright has active handles
988+
// Give it 2 seconds for any pending operations to complete
989+
if (!process.env.CODECEPT_DISABLE_AUTO_EXIT) {
990+
setTimeout(() => {
991+
if (process.listenerCount('exit') === 0) {
992+
// No other exit handlers, safe to exit
993+
process.exit(process.exitCode || 0)
994+
}
995+
}, 2000).unref()
996+
}
985997
}
986998

987999
_session() {

0 commit comments

Comments
 (0)