EADDRINUSE errors when tests run concurrently
See original GitHub issueWe have multiple tests in our test suite that depend on mockttp, making use of its capability to randomly assign a port, and when Jest runs these tests concurrently we occasionally see errors in the form:
listen EADDRINUSE: address already in use :::8000
at MockttpServer.<anonymous> (node_modules/mockttp/src/server/mockttp-server.ts:138:22)
at fulfilled (node_modules/mockttp/dist/server/mockttp-server.js:8:58)
To reproduce this issue we set up the following test:
import { getLocal } from 'mockttp';
describe('mockttp tests running in parallel', () => {
const mockServer = getLocal();
beforeAll(async () => {
await mockServer.start();
});
afterAll(async () => await mockServer.stop());
it('should pass', () => {
expect(true).toBe(true);
});
});
and then executed:
printf %s\\n {0..64} | xargs -n 1 -P 16 npx jest <test-name>
to run 16 instances of the test in parallel (on our 16 core machine) 4 times in a row. On most runs we see this issue occurring.
Can we introduce some kind of locking or retry mechanism in mockttp-server.start
, or do you think we’re using the library in a way it wasn’t intended to be used?
Tested on version 0.21.2
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Node, React, with concurrently, EADDRINUSE :::8000 error
When I execute yarn dev I get the following error: $ concurrently "yarn server" "yarn client" $ nodemon index.js $ yarn start --prefix...
Read more >EADDRINUSE error when running node integration tests
It's my understanding that while Jest runs the tests within each file sequentially, it runs the different test files in parallel. It seems...
Read more >How to kill server when seeing “EADDRINUSE: address ...
When this EADDRINUSE issue has already happened, in order to resolve it, you need to kill the process manually. In order to do...
Read more >listen EADDRINUSE: address already in use :::5000-node.js
Coding example for the question node:events:304 Error: listen EADDRINUSE: ... I changed "dev": "concurrently \"yarn run server\" \"yarn run client\"" to ...
Read more >EADDRINUSE when watching tests with mocha and supertest
The problem happens when we run tests without closing the server, as is the case when we are watching our tests. Like I...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is now published as v1.0.1 👍
This has now been released, as part of Mockttp 1.0.0 🎉. Enjoy, let me know if you have any other trouble.