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(common): Servers#listen() port number validation #383

Closed
petermetz opened this issue Nov 10, 2020 · 0 comments · Fixed by #384
Closed

fix(common): Servers#listen() port number validation #383

petermetz opened this issue Nov 10, 2020 · 0 comments · Fixed by #384
Assignees
Labels
bug Something isn't working
Milestone

Comments

@petermetz
Copy link
Contributor

Describe the bug

Because Javascript treats the number zero (0) as a falsy value, the check for truthy-ness in the Servers#listen() method does not work when one wants to specify the port as 0 for the purpose of allocating a random port.

To Reproduce

Servers.listen({ port: 0}) then watch it burn.

Expected behavior

Does not throw in the event of port being 0.

Logs/Stack traces

operator: fail
    stack: |-
      Error: Error: "Servers#listen() arg options.port" is falsy, need a truthy value.
          at Test.assert [as _assert] (REDACTED/node_modules/tape/lib/test.js:260:54)
          at Test.bound [as _assert] (REDACTED/node_modules/tape/lib/test.js:84:32)
          at Test.fail (REDACTED/node_modules/tape/lib/test.js:354:10)
          at Test.bound [as fail] (REDACTED/node_modules/tape/lib/test.js:84:32)
          at onError (REDACTED/node_modules/tape/lib/test.js:114:18)
          at processTicksAndRejections (internal/process/task_queues.js:97:5)

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):

v0.2.0

cc: @takeutak @sfuji822 @jonathan-m-hamilton

@petermetz petermetz added the bug Something isn't working label Nov 10, 2020
@petermetz petermetz added this to the v0.3.0 milestone Nov 10, 2020
@petermetz petermetz self-assigned this Nov 10, 2020
petermetz added a commit to petermetz/cacti that referenced this issue Nov 10, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Nov 12, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Dec 1, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Dec 11, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Dec 11, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Dec 11, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit to petermetz/cacti that referenced this issue Dec 14, 2020
Fixes hyperledger-cacti#383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz added a commit that referenced this issue Dec 15, 2020
Fixes #383

Ensures that the when specifying port 0 the liste()
method does not throw an exception since it is
perfectly valid to bind to port zero in general.

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant