apify-sdk-js icon indicating copy to clipboard operation
apify-sdk-js copied to clipboard

Flaky tests for websockets

Open B4nan opened this issue 2 years ago • 0 comments

After the vitest refactor, sometimes the CI fails with the following error:

⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯ Uncaught Exception ⎯⎯⎯⎯⎯
Error: listen EADDRINUSE: address already in use :::9099
 ❯ Server.setupListenHandle [as _listen2] node:net:1463:16
 ❯ listenInCluster node:net:1511:12
 ❯ Server.listen node:net:1599:7
 ❯ new WebSocketServer node_modules/ws/lib/websocket-server.js:90:20
 ❯ test/apify/events.test.ts:15:15
     13| 
     14|     beforeEach(() => {
     15|         wss = new WebSocket.Server({ port: 9099 });
       |               ^
     16|         vitest.useFakeTimers();
     17|         process.env[ACTOR_ENV_VARS.EVENTS_WEBSOCKET_URL] = 'ws://local…
 ❯ node_modules/@vitest/runner/dist/index.js:135:14
 ❯ node_modules/@vitest/runner/dist/index.js:58:[26](https://github.com/apify/apify-sdk-js/actions/runs/7004682693/job/19052930717?pr=257#step:9:27)
 ❯ node_modules/@vitest/runner/dist/index.js:582:59
 ❯ callSuiteHook node_modules/@vitest/runner/dist/index.js:582:47

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { code: 'EADDRINUSE', errno: -98, syscall: 'listen', address: '::', port: 9099 }
This error originated in "test/apify/events.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "should send persist state events in regular interval". It might mean one of the following:
- The error was thrown, while Vitest was running this test.
- This was the last recorded test before the error was thrown, if error originated after test finished its execution.

https://github.com/apify/apify-sdk-js/actions/runs/7004682693/job/19052930717?pr=257

B4nan avatar Nov 27 '23 12:11 B4nan