Skip to content

fix(pinia-orm): fall back to strong refs when WeakRef is unavailable#2031

Merged
CodeDredd merged 1 commit into
mainfrom
fix/weakref-fallback
Jul 19, 2026
Merged

fix(pinia-orm): fall back to strong refs when WeakRef is unavailable#2031
CodeDredd merged 1 commit into
mainfrom
fix/weakref-fallback

Conversation

@CodeDredd

Copy link
Copy Markdown
Owner

Bug

The default query cache (WeakCache) constructs WeakRef instances on every set(). Environments without WeakRef support — notably Cloudflare Workers — throw WeakRef is not defined as soon as anything is cached, which breaks Nuxt SSR on that platform (#1949).

Fix

WeakCache#set() now falls back to an internal StrongRef (same deref() shape) when WeakRef is not available. Degraded mode holds values strongly — acceptable for short-lived worker isolates, and far better than crashing. No behavior change where WeakRef exists.

Tests

New test stubs WeakRef away (vi.stubGlobal) and verifies set/get/has/iteration still work. Full suite green.

fixes #1949

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-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.40%. Comparing base (018acee) to head (6c3d0a5).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CodeDredd
CodeDredd merged commit c6bebb9 into main Jul 19, 2026
13 checks passed
@CodeDredd
CodeDredd deleted the fix/weakref-fallback branch July 19, 2026 21:37
@github-actions github-actions Bot mentioned this pull request Jul 20, 2026
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.

WeakRef is not supported in Cloudflare Workers

2 participants