Skip to content

Fix/refactor autoexit#5556

Merged
DavertMik merged 13 commits into
4.xfrom
fix/refactor-autoexit
May 10, 2026
Merged

Fix/refactor autoexit#5556
DavertMik merged 13 commits into
4.xfrom
fix/refactor-autoexit

Conversation

@DavertMik
Copy link
Copy Markdown
Contributor

Motivation/Description of the PR

  • Description of this PR, which problem it solves
  • Resolves #issueId (if applicable).

Applicable helpers:

  • Playwright
  • Puppeteer
  • WebDriver
  • REST
  • FileHelper
  • Appium
  • TestCafe

Applicable plugins:

  • allure
  • autoDelay
  • autoLogin
  • customLocator
  • pauseOnFail
  • coverage
  • retryFailedStep
  • screenshotOnFail
  • selenoid
  • stepByStepReport
  • stepTimeout
  • wdio
  • subtitles

Type of change

  • 🔥 Breaking changes
  • 🚀 New functionality
  • 🐛 Bug fix
  • 🧹 Chore
  • 📋 Documentation changes/updates
  • ♨️ Hot fix
  • 🔨 Markdown files fix - not related to source code
  • 💅 Polish code

Checklist:

  • Tests have been added
  • Documentation has been added (Run npm run docs)
  • Lint checking (Run npm run lint)
  • Local tests are passed (Run npm test)

DavertMik and others added 13 commits April 26, 2026 22:27
…hes pause()

When run_test's timeout was shorter than the time the test needed to
reach pause() (e.g. 50ms timeout vs 30s Playwright helper timeout),
Mocha kept running in the background, eventually entered paused state
forever (because cancelRun had reset abortRun=false), and every
subsequent run_test threw "Mocha instance is currently running tests".
The only recovery was killing the MCP process.

Three changes:

- lib/codecept.js: capture the Runner returned by mocha.run() as
  mocha.runner, so callers have a clean handle to abort. Previously
  the return value was discarded.

- cancelRun(): call mocha.runner.abort() to actually stop Mocha (sets
  the runner's _abort flag, makes the run callback fire fast). Drop
  the 5s race against pendingRunPromise — with runner.abort() the
  promise settles quickly; relying on a short race meant a 30s
  Playwright step would outlive the cancel and Mocha state stayed
  RUNNING.

- abortRun lifecycle: stop resetting it inside cancelRun. Reset it at
  the start of each new run_test / run_step_by_step instead. This way
  if a late pause() fires after cancelRun returns (test reached pause
  asynchronously after the timeout), setPauseHandler still rejects it
  instead of trapping forever.

Repro fixed:
  run_test({timeout: 50})  → Timeout after 50ms
  run_test({timeout: 60000}) → completed, stats: {tests:1, passes:1}
(was: second call permanently failed with "Mocha is already running")

Refs: testomatio/e2e-tests#103

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread lib/command/run.js
}, 1000).unref()
}
}
await autoExit()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kobenguyent I refactored the previously written code for it
I hope having a single point would make this it clearer and easy to control

@DavertMik DavertMik merged commit fb28db2 into 4.x May 10, 2026
10 checks passed
@DavertMik DavertMik deleted the fix/refactor-autoexit branch May 10, 2026 21:23
DavertMik added a commit that referenced this pull request May 11, 2026
* fix(plugins): resolve async race conditions in aiTrace, analyze, screencast, pageInfo, heal

Fix 8 bugs across 6 plugin files where async operations outside the
recorder chain, missing force flags, and incorrect filtering caused
silent data loss, premature process exit, and broken healing limits.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(analyze,screencast): rework for new autoExit + fix unit tests

analyze.js: CODECEPT_DISABLE_AUTO_EXIT was removed in #5556 (autoExit
refactor). Push printReport onto the recorder so it's awaited inside
codecept.run()'s done() before autoExit fires.

screencast tests: emit event.test.started in unit tests to match the
production event sequence (asyncWrapper.js fires it between
event.test.before and the first event.step.started).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: gololdf1sh <oleksandr.kiriukhin@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: DavertMik <davert@testomat.io>
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