Skip to content

Commit 7bb0322

Browse files
biilmannerezrokah
andauthoredJan 25, 2022
fix(command-dev): optionally pass settings to getNetlifyGraphConfig (#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>
1 parent 4e5eb1a commit 7bb0322

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
 

‎src/commands/dev/dev.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ const dev = async (options, command) => {
308308
} else if (startNetlifyGraphWatcher) {
309309
const netlifyToken = await command.authenticate()
310310
await OneGraphCliClient.ensureAppForSite(netlifyToken, site.id)
311-
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options })
311+
const netlifyGraphConfig = await getNetlifyGraphConfig({ command, options, settings })
312312

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

‎src/lib/one-graph/cli-netlify-graph.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const filterRelativePathItems = (items) => items.filter((part) => part !== '')
2929
* @param {import('../base-command').BaseCommand} command
3030
* @return {NetlifyGraphConfig} NetlifyGraphConfig
3131
*/
32-
const getNetlifyGraphConfig = async ({ command, options }) => {
32+
const getNetlifyGraphConfig = async ({ command, options, settings }) => {
3333
const { config, site } = command.netlify
3434
config.dev = { ...config.dev }
3535
config.build = { ...config.build }
@@ -44,11 +44,12 @@ const getNetlifyGraphConfig = async ({ command, options }) => {
4444
}
4545

4646
/** @type {Partial<import('../../utils/types').ServerSettings>} */
47-
let settings = {}
48-
try {
49-
settings = await detectServerSettings(devConfig, options, site.root)
50-
} catch (detectServerSettingsError) {
51-
error(detectServerSettingsError)
47+
if (!settings) {
48+
try {
49+
settings = await detectServerSettings(devConfig, options, site.root)
50+
} catch (detectServerSettingsError) {
51+
error(detectServerSettingsError)
52+
}
5253
}
5354

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

0 commit comments

Comments
 (0)