Skip to content

fix(analytics): discard in-flight cache loader after invalidation (#463) - #465

Open
Proxima84-code wants to merge 1 commit into
MergeFi:mainfrom
Proxima84-code:fix/ttl-cache-invalidation-463
Open

Proxima84-code wants to merge 1 commit into
MergeFi:mainfrom
Proxima84-code:fix/ttl-cache-invalidation-463

Conversation

@Proxima84-code

Copy link
Copy Markdown

Resolves #463.

Root Cause

TtlCache.invalidate() previously cleared only this.entry, ignoring any concurrent this.inflight promise. When the loader finished, it unconditionally stored stale data into this.entry with a fresh TTL, defeating the invalidation.

Fix

  • Introduced a generation sequence counter to TtlCache.
  • invalidate() increments the generation and clears both entry and inflight.
  • The in-flight loader resolves and sets this.entry only if currentGen === this.generation.
  • Added unit tests in src/analytics/ttl-cache.spec.ts validating cache hits, request coalescing, and stale in-flight invalidation.

@vercel

vercel Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Proxima84-code is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

TtlCache.invalidate() is lost if it lands while a load is in flight — stale platform summary is re-cached for a full TTL

1 participant