Skip to content
This repository was archived by the owner on Jun 7, 2026. It is now read-only.

fix(gateway): resolve flaky tests from port conflicts and shared state - #75

Merged
matthew-petty merged 2 commits into
mainfrom
fix/70-72-flaky-tests
Dec 27, 2025
Merged

fix(gateway): resolve flaky tests from port conflicts and shared state#75
matthew-petty merged 2 commits into
mainfrom
fix/70-72-flaky-tests

Conversation

@matthew-petty

Copy link
Copy Markdown
Member

Summary

Changes

Issue #72 - EADDRINUSE

  • Set PORT=0 in app.test.ts to get an OS-assigned port (matching sdk.integration.test.ts)
  • Added afterAll hook to properly close the server after tests

Issue #70 - Socket hang up

  • Configured vitest to use poolMatchGlobs for targeted test isolation
  • Integration and concurrency tests run in forks pool (isolated processes)
  • Other tests run in parallel threads pool for speed

Test plan

  • Run bun run test multiple times - all 143 tests pass consistently
  • Verify no EADDRINUSE errors
  • Verify no socket hang up errors

Fixes #70
Fixes #72

Fixes #72

The integration tests in app.test.ts were using the default port 3100,
which conflicts with sdk.integration.test.ts when running in parallel.

Changes:
- Set PORT=0 in vi.hoisted block to get an OS-assigned port
- Add afterAll hook to properly close the server after tests
- Import server export for cleanup
Fixes #70

The concurrency module has shared state that was causing "socket hang up"
errors when concurrency.test.ts ran in parallel with integration tests.

Changes:
- Use poolMatchGlobs to run integration and concurrency tests in forks pool
- Other tests continue to run in parallel threads pool for speed
- Forks pool provides process isolation, preventing shared state conflicts
@codecov

codecov Bot commented Dec 27, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@matthew-petty
matthew-petty merged commit a34fa7d into main Dec 27, 2025
3 checks passed
@matthew-petty
matthew-petty deleted the fix/70-72-flaky-tests branch December 27, 2025 15:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: EADDRINUSE port conflict in integration tests Flaky test: concurrency.test.ts 'socket hang up' when run in parallel

1 participant