From 967a78d657d0a0962eb8df7341e5e04dde917382 Mon Sep 17 00:00:00 2001 From: "Shibata, Tats" <868951+rewse@users.noreply.github.com> Date: Sun, 22 Mar 2026 11:57:47 +0900 Subject: [PATCH] fix(cli): handle incomplete localStorage in Node.js v25+ Node.js v25 provides a built-in localStorage on globalThis, but without `--localstorage-file` it is an empty object lacking getItem/setItem. The existing check `!("localStorage" in globalThis)` passes, so the polyfill is skipped and the CLI crashes with: TypeError: localStorage.getItem is not a function Check for getItem as well so the polyfill is applied when the native implementation is incomplete. --- src/apps/cli/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apps/cli/main.ts b/src/apps/cli/main.ts index 442d9c9..fac1072 100644 --- a/src/apps/cli/main.ts +++ b/src/apps/cli/main.ts @@ -3,7 +3,7 @@ * Command-line version of Self-hosted LiveSync plugin for syncing vaults without Obsidian */ -if (!("localStorage" in globalThis)) { +if (!("localStorage" in globalThis) || typeof (globalThis as any).localStorage?.getItem !== "function") { const store = new Map(); (globalThis as any).localStorage = { getItem: (key: string) => (store.has(key) ? store.get(key)! : null),