Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize port used for function discovery to reduce race conditions. #5444

Merged
merged 3 commits into from
Jan 21, 2023

Conversation

taeold
Copy link
Contributor

@taeold taeold commented Jan 20, 2023

When spinning up admin server for function discovery, we rely on portfinder.getPort() function to find an open port for the admin server to listen.

portfinder starts from a base port number (e.g. 9005), trying incrementally larger number until an open port is found. This mechanism can lead to race condition when multiple processes look for an open port from the same base port number.

This PR adds a small jitter to the base port number when calling portfinder to reduce likeliness of a race condition.

Fixes #5418.

@codecov-commenter
Copy link

codecov-commenter commented Jan 20, 2023

Codecov Report

Base: 56.43% // Head: 56.43% // No change to project coverage 👍

Coverage data is based on head (a960c76) compared to base (d4a2ce8).
Patch coverage: 33.33% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5444   +/-   ##
=======================================
  Coverage   56.43%   56.43%           
=======================================
  Files         313      313           
  Lines       21232    21232           
  Branches     4333     4333           
=======================================
  Hits        11983    11983           
  Misses       8211     8211           
  Partials     1038     1038           
Impacted Files Coverage Δ
src/deploy/functions/runtimes/node/index.ts 40.62% <33.33%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@taeold taeold merged commit 58f81d0 into master Jan 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't run multiple emulators: Error: listen EADDRINUSE: address already in use :::9005
3 participants