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

CLI arg --host displays network ip for "dev" but not for "preview" (on Node >=18.10) #5303

Closed
1 task
zEh- opened this issue Nov 5, 2022 · 0 comments · Fixed by #5430
Closed
1 task

CLI arg --host displays network ip for "dev" but not for "preview" (on Node >=18.10) #5303

zEh- opened this issue Nov 5, 2022 · 0 comments · Fixed by #5430
Assignees
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)

Comments

@zEh-
Copy link

zEh- commented Nov 5, 2022

What version of astro are you using?

1.6.3

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the Bug

Expected

  ┃ Local    http://localhost:3000/
  ┃ Network  http://192.168.***:3000/

Actual

  ┃ Local    http://localhost:3000/
  ┃ Network  unable to find network to expose

Cause

Manual version comparison is flawed here.

The current code nodeVersion >= 18.4 wrongly results for LTS in 18.12 >= 18.4 being false.

This should suffice:

(networkInterface) =>
  networkInterface.address && ['IPv4', 4].includes(networkInterface.family)

Semver seems overkill:

(networkInterface) =>
  networkInterface.address &&
  networkInterface.family ===
    (semver.satisfies(process.version, "<18 || >=18.4") ? 'IPv4' : 4)

Might be a good idea to add a comment above mentioning nodejs/node#42787 as @types/node declarations don't reflect this old bug.

Link to Minimal Reproducible Example

Participation

  • I am willing to submit a pull request for this issue.
@zEh- zEh- changed the title CLI arg --host works for "dev" but not for "preview" (on Node >=18.10) CLI arg --host displays network ip for "dev" but not for "preview" (on Node >=18.10) Nov 5, 2022
@bluwy bluwy self-assigned this Nov 14, 2022
@bluwy bluwy added the - P3: minor bug An edge case that only affects very specific usage (priority) label Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants