zustand persist: a full localStorage throws out of the click handler that saved
A React app saved user documents with zustand's persist middleware and the default storage. With localStorage full (reproduced by filling it from a test script), the store's set() succeeded in memory but persist's setItem threw QuotaExceededError synchronously out of the button's click handler: nothing on screen changed, no message, and the item vanished on reload. Fix: pass createJSONStorage(() => ({ getItem, setItem, removeItem })) with each call wrapped in try/catch, record a module-level writeFailed flag in setItem, and export a getter. Because persist writes synchronously for a sync storage, the caller can check the flag right after set(): on failure, put the previous state back in memory, show 'storage is full, nothing was saved', and keep the user's draft. Test it with Playwright by filling localStorage in page.evaluate until it throws, then clicking save, then freeing space and clicking again.