Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe PR upgrades ChangesLRU Cache TTL Handling
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to The described upgrade updates the cache calls and covers the relevant TTL cases; no specific user-impacting issue requiring resolution before merge is established. Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation [ Full details: Engage In Review FeedbackExplanation The available review metadata reports zero actionable findings in the current review. It also states that this does not establish whether earlier posted comments are absent or resolved. The checkout contains no review-discussion export, so it cannot show whether earlier feedback received discussion and either a commit or reviewer retraction.
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10671 +/- ##
=======================================
Coverage 93.82% 93.82%
=======================================
Files 192 192
Lines 16875 16882 +7
Branches 252 252
=======================================
+ Hits 15833 15840 +7
Misses 1020 1020
Partials 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
46ecb8f to
14ed717
Compare
14ed717 to
408303a
Compare
Issue
Two related defects in the in-memory cache adapter, plus the
lru-cacheupgrade that makes one of them fatal.1. Per-entry TTL has never been applied.
LRUCache.put()passedttlaslru-cache's third positional argument, but that slot is an options object. Destructuring a number yieldsundefinedfor every option, so the per-entry TTL was silently discarded and the cache-wide TTL always won. Verified on the currently pinned11.2.7:The practical effect is that
RedisCacheAdapterhonours per-entry TTLs whileInMemoryCacheAdapterignores them, so the two adapters disagree. For exampleParseGraphQLControllercaches its config withput(configCacheKey, graphQLConfig, 60000)but in-memory it actually expires aftercacheTTL(5s by default).2.
this.ttlwas never assigned. The default parameterput(key, value, ttl = this.ttl)read a property the constructor never set, so it was alwaysundefined.3.
lru-cache@11.3.0turns defect 1 into a hard failure. In an undocumented change (absent from the upstream CHANGELOG),set(),get(),has(),peek(),fetch(),forceFetch()andmemo()now write back onto the caller-supplied options object:Passing a non-object therefore throws. Bisected:
11.2.7OK,11.3.0–11.5.3throwTypeError: Cannot create property 'status' on number '60000'. This is why the Dependabot bump (#10596) fails every CI job.Two call sites passed a positional number, both on default code paths:
src/Adapters/Cache/LRUCache.js— reached fromParseGraphQLController._putCachedGraphQLConfigthrough the defaultInMemoryCacheAdapter.src/LiveQuery/ParseLiveQueryServer.ts— the invalid-session-token negative cache, which fires whenever a LiveQuery client presents anINVALID_SESSION_TOKEN(the path covered by the spec for GHSA-2xm2-xj2q-qgpj).This PR supersedes #10632, whose
LRUCache.jsfix it adopts, and #10596.Closes #10596
Closes #10632
Approach
Fix both call sites to pass an options object, assign
this.ttlin the constructor, and bumplru-cacheto11.5.2.LRUCache.put()now maps the TTL explicitly:Infinity->0, which is howlru-cacheexpresses "never expires", matchingRedisCacheAdapter'sInfinityhandling.{ ttl }.undefined, which is howlru-cacheexpresses "use the cache-wide TTL".Infinityis deliberately not forwarded as-is. Node cannot express it as a timer duration: underttlAutopurgeit emitsTimeoutOverflowWarning: Infinity does not fit into a 32-bit signed integerand clamps the timer to 1ms, so the purge timer re-fires every millisecond.ParseLiveQueryServernow passes{ ttl: this.config.cacheTimeout }. That one is behaviour-preserving by construction:authCacheis built withttl: config.cacheTimeout, so the explicit value equals the cache-wide one.Behaviour change
Per-entry TTLs now take effect in the in-memory adapter. The most visible consequence is that the GraphQL config cache honours its intended
60000instead of falling back tocacheTTL(5s by default), bringing it in line with the Redis adapter.Breaking Changes
None.
Tests
Adds specs covering per-entry TTL longer than the cache TTL, shorter than the cache TTL,
Infinity, a non-numeric TTL, and an omitted TTL. Four of them fail against the unfixed adapter on11.5.2with the sameTypeErrorseen in CI, and all pass with the fix.Verified locally:
InMemoryCacheAdapter8/8,CacheController5/5,ParseGraphQLController25/25,ParseLiveQuery56/56, lint clean.Known adapter difference, not changed here
RedisCacheAdaptertreatsttl === 0as "do not cache at all" (it returns before writing), whereas the in-memory adapter treats0as "not a positive TTL" and falls back to the cache-wide value. This PR keeps the existing in-memory behaviour rather than widening scope; worth a follow-up if full parity is wanted.Tasks
spec/InMemoryCacheAdapter.spec.jsSummary by CodeRabbit
Bug Fixes
Maintenance