Skip to content

Instantly share code, notes, and snippets.

@anodynos
Created April 25, 2018 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anodynos/88bd8cf36a58ef94a68ed1603dbfdc50 to your computer and use it in GitHub Desktop.
Save anodynos/88bd8cf36a58ef94a68ed1603dbfdc50 to your computer and use it in GitHub Desktop.
Alsatian test suite on express server not exiting
A bug with "alsatian@2.2.1" or our server / setup, prevents the Alsatian test runner from finishing.
Our initial idea was the express Server was not closing, a common nodejs scenario, which would prevent the tests from finishing.
But it seems it is not for sure the case, plus we can't reproduce the problem ouside our codebase - hence we can't open an issue on the Alsatian repo.
Things we've tried:
- Tried combination of above and most other tricks in [stackoverflow](https://stackoverflow.com/questions/14626636/how-do-i-shutdown-a-node-js-https-server-immediately?noredirect=1&lq=1).
- Tried manually keeping track & destroying open sockets (`server.on("connection", socket => // add to array` and `socket.on('close', => // remove from array )` and calling `socket.destroy` on remaining ones.
- Tried `setImmediate(() => this.server.emit('close'))`
- Tried `killable`, `http-shutdown`, `stoppable`, still no luck.
- Tried `db.close()` (which calls `this.sequelize.close()`), not working.
- Finally tried some dummy tests with a simple express() server and it worked fine, so there is something wrong with something else (DB most likely, maybe some middleware, mailer etc).
Till then, we live with this awful hack `setTimeout(() => process.exit(0), 90 * 1000);`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment