fix: process hangs when _beforeSuite helper hook throws#5515
Open
fix: process hangs when _beforeSuite helper hook throws#5515
Conversation
Add recorder.catch() for suite.before and suite.after events in helpers listener. Unlike all other hook events (test.before, test.after, etc.), these suite-level events had no catch handler, so rejected promises from helper hooks like Playwright._beforeSuite() were unhandled — mocha's done callback was never called, causing the process to hang indefinitely. Also disable store.dryRun during check command's helper setup/teardown verification so it actually launches the browser and can detect issues like missing Playwright browser installations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
recorder.catch()for suite-level hook events inlib/listener/helpers.js. Theevent.suite.beforeandevent.suite.afterlisteners were missing error catch handlers — unlike every other hook event (test.before,test.after,test.passed,test.failed,test.started). When a helper's_beforeSuite()threw (e.g., Playwright browser not installed), the rejected promise was unhandled, mocha'sdonecallback was never called, and the process hung indefinitely.codeceptjs checkby temporarily disablingstore.dryRunaround the helper setup/teardown verification inlib/command/check.js. Previously, Playwright skipped browser launch in dryRun mode, socheckcouldn't detect missing browser installations.Root cause
In 3.x, suite hooks were wrapped via
injectHook()which calledrecorder.catch()after event emission. In the 4.x ESM rewrite,suiteSetup()setsrecorder.errHandler(doneFn)but no.catch()was appended to the promise chain to invoke it — so errors in_beforeSuitewere silently swallowed.Test plan
codeceptjs check— verify it now actually launches/closes the browser (HELPERS BEFORE / HELPERS AFTER pass)codeceptjs checkreports the error instead of passing silently_beforeSuitefails during a real test run, the error is reported and the process exits instead of hanging🤖 Generated with Claude Code