Repository navigation
Write Node persistent caches without node-persist's write queue - #346
Merged
Merged
Conversation
…ite queue Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InventivetalentDev
marked this pull request as ready for review
October 21, 2026 19:11
…ENTS.md sentence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
NodeEnv.openCachecreates node-persist stores withwriteQueue: false, so a persistentputresolves as soon as its file is written.NodeCacheserializes writes to the same key while allowing different keys to write concurrently.putreturns the supplied value, matching itsPromise<T>contract, instead of node-persist's stored record.Why
With node-persist's default write queue, a
setItemthat starts while another write is in progress resolves from a one-secondsetIntervalthat node-persist unrefs.PersistentCache.getOrLoadawaits that write, so a load can stall for up to a second. In a short-lived Node process, nothing else keeps the event loop alive, and Node exits with the load still pending (exit code 13 for an unsettled top-levelawait).Risk
Low. Only Node persistent caches change. Same-key writes must remain ordered to prevent corrupt JSON; a failed write must reject its caller without preventing later writes to that key.
Testing
yarn workspace minerender typecheckandyarn build:lib: pass.writeQueue: falsechange; it passes with the per-key queue.Note
AI-assisted.