Repository navigation
fix: share raw metadata across in-flight requests - #13079
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe npm resolver now shares the original metadata fetch promise among concurrent callers, then replaces it with a body-less cached result after settlement. Cache clearing and rejection handling avoid stale entries, with tests covering concurrency, lifecycle races, and serialization behavior. ChangesMetadata cache behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Assessment against linked issues
Sequence Diagram(s)sequenceDiagram
participant WorkspaceResolvers
participant memoizeFetchMetadata
participant Registry
WorkspaceResolvers->>memoizeFetchMetadata: request package metadata
memoizeFetchMetadata->>Registry: fetch metadata
WorkspaceResolvers->>memoizeFetchMetadata: concurrent request
memoizeFetchMetadata-->>WorkspaceResolvers: share raw inflight result
Registry-->>memoizeFetchMetadata: settle request
memoizeFetchMetadata-->>WorkspaceResolvers: store body-less settled result
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Confidence Score: 5/5The change is safe to merge — it corrects a narrow, well-understood caching invariant without altering any external API or on-disk format. The logic is straightforward: one Map, one identity guard, and two settlement paths that are each unit-tested and integration-tested. The microtask ordering guarantee (settlement handlers registered before the caller's await continuation) means the cache swap is always atomic from the caller's perspective. All edge cases (clear during flight, rejection after replacement, notModified pass-through) have dedicated test coverage and the tests match the implementation precisely. No files require special attention. Reviews (2): Last reviewed commit: "test: cover the metadata re-serializatio..." | Re-trigger Greptile |
Add a regression test at the pickPackage/memo-cache boundary: 20 projects joining one in-flight fetch must mirror the fetched body rather than each re-serialize it. Against the pre-fix implementation it fails with 19 re-serializations, one per non-initiating caller. Cover the rejection-path identity guard too, which no test exercised. Correct the jsonText contract docs, which still described the pre-fix behaviour, and restore the rationale for dropping the body once the request settles.
84386c8 to
851100e
Compare
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Bumps the pinned packageManager version from [email protected] to [email protected], matching the version already running cleanly in commercetools/merchant-center-application-kit. This version picks up two confirmed upstream memory-regression fixes that predate nimbus's previously pinned 11.10.0: - pnpm/pnpm#12868 (pnpm 11 resolution uses ~47% more memory than pnpm 10 on a cold metadata cache), fixed by pnpm/pnpm#12870. - pnpm/pnpm#13077 (pnpm 11.11+ OOMs by re-serializing full package metadata for concurrent workspace cache hits), fixed by pnpm/pnpm#13079. When Renovate updates lockfile artifacts on this repo, its Node process OOM-crashes with these regressions present (#1886, #1885, #1880 all failing with FATAL ERROR: JavaScript heap out of memory). This bump addresses that root cause. pnpm-lock.yaml required no changes: pnpm 11.14.0 resolves the existing dependency graph identically to 11.10.0 for this repo.
Updates the pinned packageManager field from [email protected] to [email protected], matching the version already running cleanly in commercetools/merchant-center-application-kit. pnpm 11.10.0 predates two confirmed upstream memory regressions in the resolver: pnpm/pnpm#12868, fixed by pnpm/pnpm#12870 (merged 2026-07-09), and pnpm/pnpm#13077, fixed by pnpm/pnpm#13079 (merged 2026-07-16). [email protected] was released 2026-07-17, after both fixes landed. ui-kit is not currently seen OOM-crashing in Renovate, unlike the sibling nimbus repo, which is being fixed separately. This bump is proactive, done alongside that fix to keep both repos on a pnpm version clear of the same class of issue. Verification performed after the bump: - Full pnpm install (node_modules removed first) with pnpm 11.14.0; pnpm-lock.yaml came out byte-identical to the pre-bump lockfile. - node scripts/check-workspace-constraints.js passes. - pnpm typecheck passes. - pnpm build (preconstruct build across all workspace packages, plus the FEC-938 declaration-leak regression guard) completes cleanly. - Representative jest runs across packages/components/buttons, packages/components/inputs/text-input, packages/components/inputs/date-input, packages/hooks, packages/utils, packages/i18n, and design-system pass for the test, ts-test, eslint, and stylelint jest projects. - publicHoistPattern (@storybook/*) and the strictDepBuilds allowBuilds list continue to work as expected; postinstall scripts for the allow-listed packages ran without error.
Summary
Motivation
memoizeFetchMetadatapreviously cached the body-less derived promise immediately. Concurrent callers therefore received metadata withoutjsonTextand each independently ranJSON.stringify(meta)before the metadata file write limiter.For Next.js, the full registry metadata is about 31 MB and contains 3,845 versions. This fan-out can exhaust the V8 heap during installs in large workspaces. The behavior was introduced by #12870.
The cache now exposes the original promise until it settles, so all in-flight callers can reuse the raw response. It then atomically swaps in the body-less promise, preserving the existing memory-retention behavior for later cache hits.
Reproduction result
With 40 concurrent callers, the Next.js full metadata, and a 1 GiB V8 heap:
JavaScript heap out of memoryChecks
memoizeFetchMetadata.test.tsJest suiteCloses #13077
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit