Skip to content

🐛 Patch Zustand persist storage fallback#2415

Closed
JFWooten4 wants to merge 1 commit into
stellar:mainfrom
JFWooten4:2145-pt-43
Closed

🐛 Patch Zustand persist storage fallback#2415
JFWooten4 wants to merge 1 commit into
stellar:mainfrom
JFWooten4:2145-pt-43

Conversation

@JFWooten4

Copy link
Copy Markdown
Contributor

This showed up across different platforms when running yarn build (at the end, after everything else succeeds).

Build error remedied:

image

Changes

This patch adds a no-op removeItem fallback when the configured Zustand persist storage adapter does not provide one.

Previously, Zustand only logged a warning when removeItem was missing. With this patch, the middleware assigns an empty fallback function instead, preventing downstream calls such as clearStorage() from failing when a custom storage implementation does not support removal.

This is applied across the CommonJS, ESM, SystemJS, and UMD middleware builds included in the package patch. It lays the framework for a more comprehensive solution if we want to tackle the Actions cleanup drops.

Copilot AI review requested due to automatic review settings April 30, 2026 10:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the repository’s patch-package override for zustand@3.7.2 to prevent failures when a custom Zustand persist storage adapter does not implement removeItem, by installing a no-op fallback.

Changes:

  • Replace the persist middleware warning for missing removeItem with a no-op removeItem assignment.
  • Apply the same fallback across the CJS, ESM (.js and .mjs), SystemJS, and UMD builds shipped in the zustand package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ElliotFriend

Copy link
Copy Markdown
Contributor

Thanks for digging into this — closing it after looking closely at what's actually happening.

Two reasons:

  1. The line this patches is a console.warn in zustand's persist middleware, not a thrown error — so the build was never actually breaking. And the fix (monkey-patching a no-op removeItem onto the caller's storage object) would silently swallow real clearStorage() failures for any zustand consumer. The root cause is Stoplight Mosaic's incomplete memoryStorage, and your own 🐞 Patch Stoplight mosaic storage fallback #2416 fixes that at the correct layer — this patch is redundant with your better one.
  2. Mechanically, it's inert anyway: the repo moved from patch-package to pnpm in switch package manager from Yarn Classic to pnpm #2493, so files in patches/ in the old format are never applied.

The Mosaic-layer conversation continues on #2416 (upstream issue first, per the comment there). Appreciate the investigation — it clearly fed the better fix.

@JFWooten4
JFWooten4 deleted the 2145-pt-43 branch July 14, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants