Problem
All JavaScript/TypeScript test PRs are blocked by a missing /etc/hosts file in the GitHub Actions CI environment, preventing vitest from resolving localhost.
Error
⎯⎯⎯⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯⎯⎯⎯⎯
Error: getaddrinfo EAI_AGAIN localhost
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:internal/dns/promises:86:17) {
errno: -3001,
code: 'EAI_AGAIN',
syscall: 'getaddrinfo',
hostname: 'localhost'
}
Impact
Blocked PRs (817 lines of code):
Coverage blocked: Cannot measure test coverage for any JS/TS files, blocking the entire Daily Test Coverage Improver workflow Phase 3.
Root Cause
The GitHub Actions runner environment is missing /etc/hosts file, which vitest's internal server requires for localhost DNS resolution.
Verification:
$ cat /etc/hosts
cat: /etc/hosts: No such file or directory
Solution
Add a step to .github/actions/daily-test-improver/coverage-steps/action.yml before running tests:
# Fix missing /etc/hosts file that causes vitest DNS resolution errors
- name: Create /etc/hosts if missing
shell: bash
run: |
if [ ! -f /etc/hosts ]; then
echo "=== /etc/hosts missing, creating it ===" | tee -a coverage-steps.log
echo "127.0.0.1 localhost" | sudo tee /etc/hosts
echo "::1 localhost" | sudo tee -a /etc/hosts
echo "=== /etc/hosts created ===" | tee -a coverage-steps.log
else
echo "=== /etc/hosts exists ===" | tee -a coverage-steps.log
cat /etc/hosts | tee -a coverage-steps.log
fi
This should be inserted as the first step before "Set up Node.js".
Attempted Workarounds (All Failed)
- ✓ Changed vitest environment to jsdom
- ✓ Added pool configuration
- ✓ Disabled watch mode
- ✓ Tried NODE_OPTIONS DNS settings
- ❌ Cannot create /etc/hosts manually (no sudo in test runs)
Benefits of Fix
Once this is fixed:
- All 6 blocked test PRs can be validated and merged
- Test coverage can be measured for 817 lines of critical code
- Daily Test Coverage Improver workflow Phase 3 can proceed
- Future test PRs won't encounter this issue
Priority
Critical - This blocks the entire test coverage improvement workflow and prevents validation of security-critical GDPR compliance code.
Related
AI generated by Daily Test Coverage Improver
To add this workflow in your repository, run gh aw add githubnext/agentics/workflows/daily-test-improver.md@e43596e069e74a65cd7d93315091672d278c2642. See usage guide.
Problem
All JavaScript/TypeScript test PRs are blocked by a missing
/etc/hostsfile in the GitHub Actions CI environment, preventing vitest from resolving localhost.Error
Impact
Blocked PRs (817 lines of code):
Coverage blocked: Cannot measure test coverage for any JS/TS files, blocking the entire Daily Test Coverage Improver workflow Phase 3.
Root Cause
The GitHub Actions runner environment is missing
/etc/hostsfile, which vitest's internal server requires for localhost DNS resolution.Verification:
Solution
Add a step to
.github/actions/daily-test-improver/coverage-steps/action.ymlbefore running tests:This should be inserted as the first step before "Set up Node.js".
Attempted Workarounds (All Failed)
Benefits of Fix
Once this is fixed:
Priority
Critical - This blocks the entire test coverage improvement workflow and prevents validation of security-critical GDPR compliance code.
Related
test/fix-vitest-localhost-dns-issue-1771751915(commit eef9f8e)