From f15afe1de39093412cea3253c0e6a437080959a8 Mon Sep 17 00:00:00 2001 From: Devvyn <22340871+opticon454@users.noreply.github.com> Date: Sat, 24 Oct 2026 00:32:20 +0800 Subject: [PATCH] test(settings): poll again when settings.json is read half-written --- test/settings-admin-only-multiuser.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/settings-admin-only-multiuser.test.ts b/test/settings-admin-only-multiuser.test.ts index e6c18120..533007ae 100644 --- a/test/settings-admin-only-multiuser.test.ts +++ b/test/settings-admin-only-multiuser.test.ts @@ -57,8 +57,12 @@ async function send(method: string, path: string, headers: Record) => boolean): Promise> { let last: Record = {}; for (let i = 0; i < 40; i++) { - last = JSON.parse(await readSettingsBytes()); - if (predicate(last)) return last; + try { + last = JSON.parse(await readSettingsBytes()); + if (predicate(last)) return last; + } catch { + // the write is not atomic: a read that lands between its truncate and its data is empty, so poll again + } await new Promise((r) => setTimeout(r, 25)); } return last;