From e5eec7cdf1c1e3539f4f386b203438d70b19d1c4 Mon Sep 17 00:00:00 2001 From: Joakim Carlstein Date: Fri, 17 Nov 2023 10:50:43 +0100 Subject: [PATCH] fix(plugin-storage-fs): throw a more descriptive error when a lock couldn't be acquired --- .changeset/calm-windows-drum.md | 5 +++++ packages/plugin-storage-fs/src/index.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/calm-windows-drum.md diff --git a/.changeset/calm-windows-drum.md b/.changeset/calm-windows-drum.md new file mode 100644 index 0000000..852993a --- /dev/null +++ b/.changeset/calm-windows-drum.md @@ -0,0 +1,5 @@ +--- +'@emigrate/plugin-storage-fs': patch +--- + +Throw a more descriptive error when a file lock couldn't be acquired diff --git a/packages/plugin-storage-fs/src/index.ts b/packages/plugin-storage-fs/src/index.ts index f030fa8..4b5b474 100644 --- a/packages/plugin-storage-fs/src/index.ts +++ b/packages/plugin-storage-fs/src/index.ts @@ -55,11 +55,15 @@ export default function storageFs({ filename }: StorageFsOptions): StoragePlugin async initializeStorage() { return { async lock(migrations) { - const fd = await fs.open(lockFilePath, 'wx'); + try { + const fd = await fs.open(lockFilePath, 'wx'); - await fd.close(); + await fd.close(); - return migrations; + return migrations; + } catch { + throw new Error('Could not acquire file lock for migrations'); + } }, async unlock() { try {