Skip to content

Commit

Permalink
fix(command-dev): optionally pass settings to getNetlifyGraphConfig (#…
Browse files Browse the repository at this point in the history
…4132)

This prevents an issue where the detectServerSettings calls acquirePort twice
and ends up blowing up by making sure we only run the detection once within
netlify dev

Co-authored-by: Erez Rokah <erezrokah@users.noreply.github.com>
  • Loading branch information
biilmann and erezrokah authored Jan 25, 2022
1 parent 4e5eb1a commit 7bb0322
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/commands/dev/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ const dev = async (options, command) => {
} else if (startNetlifyGraphWatcher) {
const netlifyToken = await command.authenticate()
await OneGraphCliClient.ensureAppForSite(netlifyToken, site.id)
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options })
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options, settings })

log(`Starting Netlify Graph session, to edit your library run \`netlify graph:edit\` in another tab`)

Expand Down
13 changes: 7 additions & 6 deletions src/lib/one-graph/cli-netlify-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const filterRelativePathItems = (items) => items.filter((part) => part !== '')
* @param {import('../base-command').BaseCommand} command
* @return {NetlifyGraphConfig} NetlifyGraphConfig
*/
const getNetlifyGraphConfig = async ({ command, options }) => {
const getNetlifyGraphConfig = async ({ command, options, settings }) => {
const { config, site } = command.netlify
config.dev = { ...config.dev }
config.build = { ...config.build }
Expand All @@ -44,11 +44,12 @@ const getNetlifyGraphConfig = async ({ command, options }) => {
}

/** @type {Partial<import('../../utils/types').ServerSettings>} */
let settings = {}
try {
settings = await detectServerSettings(devConfig, options, site.root)
} catch (detectServerSettingsError) {
error(detectServerSettingsError)
if (!settings) {
try {
settings = await detectServerSettings(devConfig, options, site.root)
} catch (detectServerSettingsError) {
error(detectServerSettingsError)
}
}

const siteRoot = [path.sep, ...filterRelativePathItems(site.root.split(path.sep))]
Expand Down

1 comment on commit 7bb0322

@github-actions
Copy link

Choose a reason for hiding this comment

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

📊 Benchmark results

Package size: 360 MB

Please sign in to comment.