Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix concurrent test-server errors #8656

Merged

Conversation

SourceR85
Copy link
Contributor

@SourceR85 SourceR85 commented Jun 9, 2023

Motivation

GitHub Actions recycling test container, causing workflows "First retry" and "Second retry" to fail, because the express-server port is already in use.

Error

> npm run build-test && node ./bin/test-browser.js

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1331:16)
    at listenInCluster (net.js:1379:12)
    at Server.listen (net.js:1465:7)
    at Function.listen (/home/runner/work/pouchdb/pouchdb/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/home/runner/work/pouchdb/pouchdb/tests/misc/pouchdb-express-router.js:31:5)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
Emitted 'error' event on Server instance at:
    at emitErrorNT (net.js:1358:8)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'EADDRINUSE',
  errno: -98,
  syscall: 'listen',
  address: '::',
  port: 3000
}

Shadows another error

Run npm test
  npm test
  shell: /usr/bin/bash -e {0}
  env:
    NODE_VERSION: 14
    SELENIUM_HUB_HOST: hub
    TEST_HOST: localhost
    CLIENT: node
    SERVER: pouchdb-server
mkdir: cannot create directory ‘pouchdb-server-install’: File exists

npm ERR! Test failed.  See above for more details.
> pouchdb-monorepo@7.0.0-prerelease test /home/runner/work/pouchdb/pouchdb
> ./bin/run-test.sh

Error: Process completed with exit code 1.

Solution

  1. run-test.sh tests the port before starting pouchdb-express-router,
    if the port isn't free, it simply increments the port.
  2. skip down-server instantiation, if port 3010 isn't free.
  3. skip pouchdb-server-install build & run, if the directory exists

With this patch, GitHub-CI should only fail on if one of the test cases fail.

@SourceR85
Copy link
Contributor Author

SourceR85 commented Jun 12, 2023

I think, I've got it now.

With this patch, GitHub-CI should only fail on if one of the test cases fail.

(side note: test-handling should be improved, but that's a story for another PR)

Copy link
Member

@garethbowen garethbowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

@garethbowen garethbowen merged commit aca4675 into pouchdb:master Jun 12, 2023
@SourceR85 SourceR85 deleted the fix-concurrent-test-server-errors branch June 12, 2023 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants