Skip to content

Commit a2bccda

Browse files
committed
Fix force exit to work unconditionally after cleanup
- Remove process.listenerCount check that was preventing exit - Force exit unconditionally after 2-second delay - Tested locally: process exits in ~9s instead of hanging - Works with both _afterSuite and _cleanup hooks - Respects process.exitCode for test failures
1 parent c212a18 commit a2bccda

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/helper/Playwright.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -874,10 +874,8 @@ class Playwright extends Helper {
874874
// Give it 2 seconds for any pending operations to complete
875875
if (!process.env.CODECEPT_DISABLE_AUTO_EXIT) {
876876
setTimeout(() => {
877-
if (process.listenerCount('exit') === 0) {
878-
// No other exit handlers, safe to exit
879-
process.exit(process.exitCode || 0)
880-
}
877+
// Force exit with the current exit code (0 for success, non-zero for failures)
878+
process.exit(process.exitCode || 0)
881879
}, 2000).unref()
882880
}
883881

@@ -1000,10 +998,8 @@ class Playwright extends Helper {
1000998
// Give it 2 seconds for any pending operations to complete
1001999
if (!process.env.CODECEPT_DISABLE_AUTO_EXIT) {
10021000
setTimeout(() => {
1003-
if (process.listenerCount('exit') === 0) {
1004-
// No other exit handlers, safe to exit
1005-
process.exit(process.exitCode || 0)
1006-
}
1001+
// Force exit with the current exit code (0 for success, non-zero for failures)
1002+
process.exit(process.exitCode || 0)
10071003
}, 2000).unref()
10081004
}
10091005
}

0 commit comments

Comments
 (0)