-
Notifications
You must be signed in to change notification settings - Fork 365
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(deps): upgrade wait-port to v1 and listen on correct address for framework #5094
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,18 +178,25 @@ const runCommand = (command, env = {}, spinner = null) => { | |
return commandProcess | ||
} | ||
|
||
/** | ||
* @typedef StartReturnObject | ||
* @property {4 | 6 | undefined=} ipVersion The version the open port was found on | ||
*/ | ||
|
||
/** | ||
* Start a static server if the `useStaticServer` is provided or a framework specific server | ||
* @param {object} config | ||
* @param {Partial<import('../../utils/types').ServerSettings>} config.settings | ||
* @returns {Promise<void>} | ||
* @returns {Promise<StartReturnObject>} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The return value is always an empty object, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either empty or has the property |
||
*/ | ||
const startFrameworkServer = async function ({ settings }) { | ||
if (settings.useStaticServer) { | ||
if (settings.command) { | ||
runCommand(settings.command, settings.env) | ||
} | ||
return await startStaticServer({ settings }) | ||
await startStaticServer({ settings }) | ||
|
||
return {} | ||
} | ||
|
||
log(`${NETLIFYDEVLOG} Starting Netlify Dev with ${settings.framework || 'custom config'}`) | ||
|
@@ -200,17 +207,17 @@ const startFrameworkServer = async function ({ settings }) { | |
|
||
runCommand(settings.command, settings.env, spinner) | ||
|
||
let port | ||
try { | ||
const open = await waitPort({ | ||
port = await waitPort({ | ||
port: settings.frameworkPort, | ||
// Cannot use `localhost` as it may point to IPv4 or IPv6 depending on node version and OS | ||
host: '127.0.0.1', | ||
host: 'localhost', | ||
Comment on lines
-207
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @danez @eduardoboucas this has caused a regressions for one of our own CI pipelines https://netlify.slack.com/archives/CPJQSPQE4/p1665509398672569 Could we use |
||
output: 'silent', | ||
timeout: FRAMEWORK_PORT_TIMEOUT, | ||
...(settings.pollingStrategies.includes('HTTP') && { protocol: 'http' }), | ||
}) | ||
|
||
if (!open) { | ||
if (!port.open) { | ||
throw new Error(`Timed out waiting for port '${settings.frameworkPort}' to be open`) | ||
} | ||
|
||
|
@@ -221,6 +228,8 @@ const startFrameworkServer = async function ({ settings }) { | |
log(NETLIFYDEVERR, `Please make sure your framework server is running on port ${settings.frameworkPort}`) | ||
exit(1) | ||
} | ||
|
||
return { ipVersion: port?.ipVersion } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oooh, I like that we can finally use optional chaining in the CLI! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea because we dropped node 12 π₯³ |
||
} | ||
|
||
// 10 minutes | ||
|
@@ -414,6 +423,8 @@ const validateGeoCountryCode = (arg) => { | |
return arg.toUpperCase() | ||
} | ||
|
||
const IP_VERSION_6 = 6 | ||
danez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* The dev command | ||
* @param {import('commander').OptionValues} options | ||
|
@@ -501,7 +512,10 @@ const dev = async (options, command) => { | |
|
||
log(`${NETLIFYDEVWARN} Setting up local development server`) | ||
|
||
const devCommand = () => startFrameworkServer({ settings }) | ||
const devCommand = async () => { | ||
const { ipVersion } = await startFrameworkServer({ settings }) | ||
settings.frameworkHost = ipVersion === IP_VERSION_6 ? '::1' : '127.0.0.1' | ||
} | ||
const startDevOptions = getBuildOptions({ | ||
cachedConfig, | ||
options, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this is a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the equal sign marks the field as optional