fix(pinia-orm): fall back to strong refs when WeakRef is unavailable#2031
Merged
Conversation
The default query cache crashed in environments without WeakRef support like Cloudflare Workers. The cache now degrades to holding values strongly instead of throwing. fixes #1949
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2031 +/- ##
=======================================
Coverage 99.40% 99.40%
=======================================
Files 82 82
Lines 3025 3025
Branches 533 533
=======================================
Hits 3007 3007
Misses 15 15
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Jul 19, 2026
Merged
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.
Bug
The default query cache (
WeakCache) constructsWeakRefinstances on everyset(). Environments withoutWeakRefsupport — notably Cloudflare Workers — throwWeakRef is not definedas soon as anything is cached, which breaks Nuxt SSR on that platform (#1949).Fix
WeakCache#set()now falls back to an internalStrongRef(samederef()shape) whenWeakRefis not available. Degraded mode holds values strongly — acceptable for short-lived worker isolates, and far better than crashing. No behavior change whereWeakRefexists.Tests
New test stubs
WeakRefaway (vi.stubGlobal) and verifies set/get/has/iteration still work. Full suite green.fixes #1949