Skip to content

fix: #752 guard purgeStaleCacheEntries against undefined storage on Node 26 - #753

Draft
ascott18 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-purgestaleentries-import-error
Draft

fix: #752 guard purgeStaleCacheEntries against undefined storage on Node 26#753
ascott18 with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-purgestaleentries-import-error

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

On Node 26, localStorage and sessionStorage are defined as globals but resolve to undefined unless --localstorage-file is passed. Because purgeStaleCacheEntries is called at module scope with no guard, importing coalesce-vue throws a TypeError before any test runs — breaking every Vitest+jsdom suite on Node 26 that transitively imports the package.

Changes

  • src/coalesce-vue/src/api-client.ts — added an early-return guard to purgeStaleCacheEntries; degrades silently to "nothing to purge" when storage is undefined/null or not a valid Storage object:
function purgeStaleCacheEntries(storage: Storage | undefined | null) {
  if (!storage || typeof storage.length !== "number") return;
  // ...
}

…ode 26

Co-authored-by: ascott18 <5017521+ascott18@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unguarded purgeStaleCacheEntries call during import fix: #752 guard purgeStaleCacheEntries against undefined storage on Node 26 Jul 30, 2026
Copilot AI requested a review from ascott18 July 30, 2026 18:25
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.

coalesce-vue: purgeStaleCacheEntries runs unguarded at import, crashing on Node 26

2 participants