forwardemail / forwardemail/supertest

Discourage implicit use of ephemeral ports in supertest.serverAddress

Open
#667 2 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.