Fix functions server port assignment #674
Merged
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.
- Summary
This PR assigns a port for the functions server in the
dev
command, sets it in the config and then uses it when starting the functions server. Previously, duplicate logic could result in the functions server starting on a specific port and then the CLI waiting for it on another port. This would prevent startup of the whole dev environment (endless dots).The port is elected as follow:
functionsPort
option innetlify.toml
if provided34567
otherwiseIf the elected port is currently in use, a random port is assigned.
This fixes the following issue: #659
- Test plan
The test must be run in a context where the functions server is started. This requires a
.functions
directory with appropriate contents.The code was tested with the following configuration:
netlify.toml
netlify.toml
but port34567
is busy11111
specified innetlify.toml
11111
specified innetlify.toml
but port11111
is busy- Description for the changelog
Fix function servers port assignment issue preventing
netlify dev
startup- A picture of a cute animal (not mandatory but encouraged)
Edit: removed #634 from fixed issues