🐛 Start the AppFixture server on the loopback address - #168
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description of the PR
Tests relying on the
AppFixturecould transiently fail with responses coming from an unrelated server, e.g. a407 Proxy Authentication Required, a404, or even a200with an unexpected body. This happened because the application's HTTP server was only started bysupertest, which listens on the IPv6 wildcard address without specifying a host. BecauseSO_REUSEADDRis set on every TCP bind, this succeeds even when another process already listens on127.0.0.1with the same port.supertestthen sends its request to127.0.0.1, and the kernel routes it to the most specific matching socket, i.e. the other process. Any loopback-only listener within the ephemeral port range is a hazard, and becausesupertestbinds a new random port for every request, a full test run has a fair chance of hitting one.The
AppFixturenow explicitly starts the server on the loopback address during initialization.supertestskips its ownlistenwhen the server already has an address, such that requests can only reach the application. As the server is bound only once, it now stays open until the fixture is deleted, which makes callingAppFixture.delete(as documented) all the more important.This PR also upgrades the dependencies, which is unrelated to the fix.
📋 Check list