Skip to content

fix: process hangs when _beforeSuite helper hook throws#5515

Open
DavertMik wants to merge 1 commit into4.xfrom
fix/beforeSuite-error-hang
Open

fix: process hangs when _beforeSuite helper hook throws#5515
DavertMik wants to merge 1 commit into4.xfrom
fix/beforeSuite-error-hang

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Summary

  • Add recorder.catch() for suite-level hook events in lib/listener/helpers.js. The event.suite.before and event.suite.after listeners 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's done callback was never called, and the process hung indefinitely.
  • Enable browser launch during codeceptjs check by temporarily disabling store.dryRun around the helper setup/teardown verification in lib/command/check.js. Previously, Playwright skipped browser launch in dryRun mode, so check couldn't detect missing browser installations.

Root cause

In 3.x, suite hooks were wrapped via injectHook() which called recorder.catch() after event emission. In the 4.x ESM rewrite, suiteSetup() sets recorder.errHandler(doneFn) but no .catch() was appended to the promise chain to invoke it — so errors in _beforeSuite were silently swallowed.

Test plan

  • Run acceptance tests with Playwright — verify browser starts, tests execute, and process exits cleanly
  • Run codeceptjs check — verify it now actually launches/closes the browser (HELPERS BEFORE / HELPERS AFTER pass)
  • Verify that when Playwright browsers are not installed, codeceptjs check reports the error instead of passing silently
  • Verify that when _beforeSuite fails during a real test run, the error is reported and the process exits instead of hanging

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant