forwardemail / forwardemail/supertest
Discourage implicit use of ephemeral ports in supertest.serverAddress
- Dominant language
- JavaScript
- Stars
- 14.4k
- Forks
- 782
- PR merge metrics
- No merged PRs in 30d
Description
I've been search for flakes in my test for weeks and I think the solution is around supertest's usage of ephemeral ports (binding to port 0).
Full writeup at at https://stackoverflow.com/questions/63343123/nodesupertest-flakes-with-client-network-socket-disconnected-before-secure-tls/63343124#63343124.
tldr; supertest.serverAddress will call app.listen(0) if the server isn't running yet. But the socket will have the SO_REUSEADDR flag set which means it can conflict with any other process that's also using SO_REUSEADDR on a port in the ephemeral range. This causes the client to spuriously fail at making a connection.
Contributor guide
Assessment
This issue has not been assessed yet.