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(windows): retry getGlobalConfig #2706

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/utils/get-global-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const globalConfigDefaults = {
cliId: uuidv4(),
}

const getGlobalConfig = async function () {
const getGlobalConfigOnce = async function () {
const configPath = getPathInHome(['config.json'])
// Legacy config file in home ~/.netlify/config.json
const legacyPath = getLegacyPathInHome(['config.json'])
Expand All @@ -28,5 +28,19 @@ const getGlobalConfig = async function () {
return configStore
}

const getGlobalConfig = async function () {
const retries = 3
for (let retry = 1; retry <= retries; retry++) {
try {
// eslint-disable-next-line no-await-in-loop
return await getGlobalConfigOnce()
} catch (error) {
if (retry === retries) {
throw error
}
}
}
}

// Memoise config result so that we only load it once
module.exports = memoizeOne(getGlobalConfig)