#17934: fix: macOS CI hangs for 2+ hours due to unhandled SSE stream errors
channel: whatsapp-web
stale
size: XS
trusted-contributor
Cluster:
Gateway Resilience and Configuration
## Summary
Fixes macOS CI hangs in web monitor inbox test suites by:
1. Setting NODE_OPTIONS="--dns-result-order=ipv4first" in macOS CI workflow
2. Adding proper teardown in afterEach/afterAll hooks to destroy SSE streams and close mock servers
## Changes
- Added dns-result-order=ipv4first to macOS CI workflow
- Added proper cleanup for event listeners in test harness afterEach hook
## Testing
Tests should fail fast on network errors instead of hanging indefinitely.
Fixes openclaw/openclaw#17911
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `--dns-result-order=ipv4first` to macOS CI workflow and proper event listener cleanup in test harness to fix 2+ hour CI hangs.
- Added DNS IPv4-first resolution to macOS CI `NODE_OPTIONS` to fix localhost resolution mismatches
- Added `sock.ev.removeAllListeners()` in `afterEach` hook to properly clean up event listeners from the shared mock socket instance
The fix addresses the root cause: the test harness shares a single `sock` object (created at module level on line 69) across all tests. Without cleanup, event listeners accumulate and prevent Vitest from detecting test completion, causing indefinite hangs. The `removeAllListeners()` call ensures each test starts with a clean slate.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are well-targeted fixes for a specific CI hang issue. The DNS resolution flag is a standard Node.js option for handling IPv6/IPv4 priority, and the event listener cleanup is a proper test hygiene practice that prevents resource leaks. Both changes are minimal, non-breaking, and address the root causes identified in the commit message.
- No files require special attention
<sub>Last reviewed commit: 4e3b8a1</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#19063: CI/macOS: disable Vitest vmForks for TS tests to stop mock-state le...
by agisilaos · 2026-02-17
74.1%
#22929: Fix NODE_EXTRA_CA_CERTS missing from LaunchAgent environment on macOS
by Clawborn · 2026-02-21
72.7%
#18792: docs: add macOS source-run troubleshooting for setup/auth issues
by yash27-lab · 2026-02-17
72.1%
#17257: fix(bonjour): stop mDNS flood on multi-NIC same-LAN setups (#17222)
by yinghaosang · 2026-02-15
71.9%
#22910: fix(browser): resolve symlinks in upload path validation
by erdinccurebal · 2026-02-21
71.6%
#21075: fix(media): use sips on Node.js + darwin to prevent Photos TCC prompt
by irchelper · 2026-02-19
71.4%
#18112: fix(daemon): gateway install on macOS ignores fnm/nvm node (#18090)
by yinghaosang · 2026-02-16
71.3%
#17912: fix: configure git to use HTTPS instead of SSH for GitHub URLs
by MisterGuy420 · 2026-02-16
71.2%
#21500: fix(test): resolve vi.mock hoisting failures on macOS runners
by irchelper · 2026-02-20
71.1%
#17456: fix(test): stabilize media root guard test against tmpdir HOME overlap
by widingmarcus-cyber · 2026-02-15
70.7%