Conversation
|
Warning Review limit reached
More reviews will be available in 1 second. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
Changesexports map expansion_keys index-based refactor
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
Updated 8:03 AM PT - Jul 2nd, 2026
❌ @robobun, your commit 0762adc has some failures in 🧪 To try this PR locally: bunx bun-pr 32312That installs a local version of the PR into your bun-32312 --bun |
|
Found 2 issues this PR may fix:
🤖 Generated with Claude Code |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/js/bun/resolve/exports-map-memory.test.ts`:
- Around line 33-42: The probe script in the exports-map-memory test has a broad
catch block that silently swallows any errors from Bun.resolveSync, allowing the
memory measurement to proceed even if the resolution fails. Remove the catch
block from the try statement and instead ensure that the tempDir setup includes
the actual target files that the resolver is expected to find, so that
Bun.resolveSync can succeed normally without needing error suppression. This
allows the subprocess to fail loudly if something is misconfigured, rather than
silently reporting a memory delta on a failed operation.
- Around line 53-57: The subprocess test is currently validating output and exit
code together with a throw statement, but should instead use expect assertions
in the proper order. Reorder the validation to first assert that stderr is empty
using expect(stderr).toBe(""), then validate the stdout output (checking that
delta is finite), and finally assert the exit code is 0. Apply this same
reordering pattern to both locations where spawned Bun processes using bunEnv
are validated, ensuring stderr assertions come before stdout and exitCode checks
to surface failures with useful diffs during test failures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7444a33d-076b-46b5-abe6-4eabd8d6245b
📒 Files selected for processing (2)
src/resolver/package_json.rstest/js/bun/resolve/exports-map-memory.test.ts
|
CI status on build #67946 (final, after rebasing onto main for #33032): 285 test jobs passed, 0 test failures, 0 error annotations. The single red job is This is agent/artifact infrastructure, not a test failure. The only other annotations are the
|
…ubtrees The e_object arm of the ExportsMap visitor pushed a full MapEntry clone into expansion_keys for every key ending in "/" or containing "*". The derived Clone on Entry recursively deep-copies Box<[u8]>, Box<[Entry]> and EntryDataMap, so each wildcard key paid a second full allocation of its condition subtree. The Zig reference at package_json.zig:1192 stores a shallow struct copy whose slice/pointer payload aliases map_data.list. Store u32 indices into list instead, and dereference them at the single consumer in ESModule resolution. PATTERN_KEY_COMPARE sorting now looks up keys through map_data.
3b0a124 to
0762adc
Compare
|
Rebased onto main to resolve a conflict with #33032 (the SIMD JSON parser rewrite), which restructured the No conflict was semantic. The deep-clone bug was still present in the rewritten Re-verified after the rebase: with main's |
|
Closing as part of a cleanup of stale pull requests. This PR has had no new commits since 2026-07-02, it conflicts with main, and its last CI run failed. This is not a judgment on the fix itself. If the problem still reproduces on a current build, reopen this PR after a rebase or open a new one against main. |
Problem
The Rust port of the
ExportsMapvisitor'se_objectarm deep-cloned the entire condition subtree for every wildcard export key. Insrc/resolver/package_json.rsthe loop did:whereas the Zig reference at
package_json.zig:1192-1196stores a shallow struct copy whosestring/[]const Entrypayload aliases the same heap data already held bymap_data.list.Packages with many wildcard exports and nested
import/require/node/defaultconditions (next, @mui/material, rxjs) therefore paid roughly 2x the heap for their exports map, andPackageJSONis interned in the process-lifetimeDirInfocache so the duplicate is never freed. Pure memory regression vs the Zig reference; no correctness change.Fix
EntryDataMap::expansion_keysis nowBox<[u32]>holding sorted indices intolist, which expresses the same sharing the Zig code gets from aliased slices. ThePATTERN_KEY_COMPAREsort looks keys up throughmap_data, and the single consumer inESModuleresolution dereferences the index before use.Verification
New
test/js/bun/resolve/exports-map-memory.test.tsbuilds two packages with identical 1000-key exports maps, one with wildcard keys and one without, resolves each in a fresh subprocess, and asserts the RSS delta of the wildcard package does not exceed the flat package's by more than 10%. A second test verifies wildcard resolution andPATTERN_KEY_COMPAREspecificity ordering are unchanged.Existing
resolve.test.tswildcard tests,import-custom-condition.test.ts, and the bundlerpackagejson/ExportsPattern*suite all pass.