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 handling of { port: '0' } #105

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

sambostock
Copy link

Being passed { port: '0' } ({ port: string }) is a Typescript type error, but we explicitly have a test that checks that it is gracefully handled, with behavior matching being passed

  • { port: 0 } ({ port: number }),
  • '0' (string), or
  • 0 (number),

which all convert the port to 0.

However, that test was actually dependent on the following leak from a test above it:

process.env.HOST = 'localhost';

Switching to vi.stubEnv and ensuring to call vi.unstubAllEnvs reveals that the behavior is broken.


This updates the behavior to apply the same check to _userOptions.port as we do to _userOptions, and coerce number and string values to integers.

Being passed `{ port: '0' }` (`{ port: string }`) is a Typescript type
error, but we explicitly have a test that checks that it is gracefully
handled, with behavior matching being passed

- `{ port: 0 }` (`{ port: number }`),
- `'0'` (`string`), or
- `0` (`number`),

which all convert the `port` to `0`.

However, that test was actually dependent on the following leak from a
test above it:

    process.env.HOST = 'localhost';

Switching to `vi.stubEnv` and ensuring to call `vi.unstubAllEnvs`
reveals that the behavior is broken.

This updates the behavior to apply the same check to `_userOptions.port`
as we do to `_userOptions`, and coerce `number` and `string` values to
integers.
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.

1 participant