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

fix: allow falsy values for "port" option #2962

Merged
merged 1 commit into from Sep 22, 2021

Conversation

henryqdineen
Copy link
Contributor

What kind of change does this PR introduce?

Fix

Did you add tests for your changes?

Open to suggestions for testing this.

If relevant, did you update the documentation?

N/A

Summary

This fixes a regression that we noticed when updating to webpack-cli@4.7.2. We are still on webpack-dev-server@3.11.2 which allows using null or 0 to automatically use a free port. In our case we are setting port: 0 and it was causing this error:

Error: listen EADDRINUSE: address already in use 127.0.0.1:8080

If webpack-cli still supports webpack-dev-server@3.11.2 it seems like it shouldn't prevent passing null or 0 as an option to port. Our current workaround is using the string '0', which is not falsy.

Does this PR introduce a breaking change?

No

Other information

webpack-dev-server@3 allows using `null` or `0` to automatically use a free port.
@henryqdineen henryqdineen requested a review from a team as a code owner September 21, 2021 18:16
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 21, 2021

CLA Signed

The committers are authorized under a signed CLA.

@alexander-akait
Copy link
Member

Please accept CLA, also I want to note - please prefer to use port: 'auto' in v4, using 0 will enable Node.js default behavior (i.e. not try to release port again)

@henryqdineen
Copy link
Contributor Author

Thank you @alexander-akait. I will make a note of that for when we upgrade to v4.

@codecov
Copy link

codecov bot commented Sep 21, 2021

Codecov Report

Merging #2962 (2f2e0d7) into master (c888861) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2962   +/-   ##
=======================================
  Coverage   95.13%   95.13%           
=======================================
  Files          31       31           
  Lines        1684     1685    +1     
  Branches      483      483           
=======================================
+ Hits         1602     1603    +1     
  Misses         82       82           
Impacted Files Coverage Δ
packages/serve/src/index.ts 84.37% <100.00%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c888861...2f2e0d7. Read the comment docs.

Copy link
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@snitin315 snitin315 merged commit da135dd into webpack:master Sep 22, 2021
anshumanv pushed a commit that referenced this pull request Oct 20, 2021
`webpack-dev-server@3` allows using `null` or `0` to automatically use a free port.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants