diff --git a/src/renderer/components/delete-cluster-dialog/save-config.ts b/src/renderer/components/delete-cluster-dialog/save-config.ts index 86ba5198a6..d9aa03e2a5 100644 --- a/src/renderer/components/delete-cluster-dialog/save-config.ts +++ b/src/renderer/components/delete-cluster-dialog/save-config.ts @@ -29,14 +29,15 @@ import { noop } from "../../utils"; export async function saveKubeconfig(config: KubeConfig, path: string) { const tmpFilePath = tempy.file(); - lockFile.lock(path).then(async (release) => { + try { + const release = await lockFile.lock(path); const contents = YAML.stringify(JSON.parse(config.exportConfig())); await fs.promises.writeFile(tmpFilePath, contents); await fs.promises.rename(tmpFilePath, path); release(); - }).catch(async (e) => { + } catch (e) { await fs.unlink(tmpFilePath, noop); throw new Error(`Failed to acquire lock file.\n${e}`); - }); + } }