Skip to content

fix(cli): add --exit flag to mocha e2e config to prevent test hanging#7934

Merged
Mo-Hussain merged 1 commit intomainfrom
fix/mocha-e2e-exit-flag
Jan 28, 2026
Merged

fix(cli): add --exit flag to mocha e2e config to prevent test hanging#7934
Mo-Hussain merged 1 commit intomainfrom
fix/mocha-e2e-exit-flag

Conversation

@Mo-Hussain
Copy link
Collaborator

@Mo-Hussain Mo-Hussain commented Jan 28, 2026

Summary

Adds the --exit flag to the Mocha e2e test configuration to prevent tests from hanging due to unclosed handles.

Problem

The Ethereum e2e tests (particularly warp-rebalancer) were hanging indefinitely after test completion, causing CI jobs to timeout after 20 minutes. Investigation revealed:

  1. Tests complete successfully (~2 minutes) but Mocha doesn't exit
  2. Open handles keep Node.js alive - likely from:
    • Child processes (rebalancer) not fully terminating due to EPIPE errors when parent closes stdio pipes
    • Metrics HTTP server not being explicitly closed
    • Testcontainers started in e2e-test.setup.ts without corresponding cleanup in after() hooks
  3. The --exit flag forces Mocha to exit after tests complete, regardless of open handles

What --exit Does

From Mocha docs:

Force Mocha to quit after tests complete. This flag is useful when you want to ensure a clean exit even if there are handles that would normally keep the event loop running.

Trade-offs

Pros Cons
Tests won't hang Masks resource leaks
CI completes reliably Hidden cleanup issues won't surface in tests
Unblocks dependent PRs Different behavior than production

Long-term Resolution

This is a temporary workaround. The proper fix involves:

  1. Rebalancer e2e improvements - These tests will be replaced with a more effective e2e tests
  2. Test setup cleanup - Add after() hooks in e2e-test.setup.ts to properly stop testcontainers
  3. Remove --exit flag once cleanup is properly handled

We are actively revamping the e2e tests for the rebalancer, and proper resource cleanup will be part of that effort.

Testing

  • Verified that the --exit flag resolves the hanging issue
  • All e2e tests pass with this change

Summary by CodeRabbit

  • Tests
    • Updated end-to-end test configuration to ensure proper process termination after test completion.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

📝 Walkthrough

Walkthrough

The Mocha end-to-end test configuration gets a bit of tweaking here. A trailing comma joins the node-option array, and an exit flag is added to ensure the process terminates cleanly after tests finish running.

Changes

Cohort / File(s) Summary
Test Configuration
typescript/cli/src/tests/ethereum/.mocharc-e2e.json
Added exit: true flag to Mocha configuration and appended trailing comma to node-option array for proper formatting.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • antigremlin
  • ltyu
  • xeno097

Poem

🧪 The tests now exit clean and neat,
No lingering processes—the job's complete,
A trailing comma, a flag set right,
Configuration's fixed, everything's tight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding the --exit flag to Mocha e2e config to resolve test hanging issues.
Description check ✅ Passed The PR description comprehensively covers all template sections with detailed context about the problem, solution, trade-offs, and long-term plans.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/mocha-e2e-exit-flag

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mo-Hussain Mo-Hussain self-assigned this Jan 28, 2026
@Mo-Hussain Mo-Hussain added this pull request to the merge queue Jan 28, 2026
Merged via the queue into main with commit cec4ff7 Jan 28, 2026
105 checks passed
@Mo-Hussain Mo-Hussain deleted the fix/mocha-e2e-exit-flag branch January 28, 2026 17:34
@github-project-automation github-project-automation bot moved this from In Review to Done in Hyperlane Tasks Jan 28, 2026
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.02%. Comparing base (22b9e14) to head (216a623).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7934   +/-   ##
=======================================
  Coverage   77.02%   77.02%           
=======================================
  Files         117      117           
  Lines        2651     2651           
  Branches      244      244           
=======================================
  Hits         2042     2042           
  Misses        593      593           
  Partials       16       16           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 71.86% <ø> (ø)
isms 81.10% <ø> (ø)
token 86.67% <ø> (ø)
middlewares 84.98% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants