fix: ensure canonicalized paths remain accessible via strong references#733
fix: ensure canonicalized paths remain accessible via strong references#733
Conversation
How to use the Graphite Merge QueueAdd the label merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #733 +/- ##
==========================================
- Coverage 94.64% 94.58% -0.06%
==========================================
Files 15 15
Lines 2914 2920 +6
==========================================
+ Hits 2758 2762 +4
- Misses 156 158 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
395834e to
b70e409
Compare
Fixes #732 - "Canonicalized path was dropped" error that could occur in CI environments. The issue was that canonicalized paths were only stored as weak references without ensuring a strong reference existed in the cache. This could cause the Arc to be immediately dropped, leading to the weak reference failing to upgrade. The fix ensures canonicalized paths are added to the cache (if not already present) before downgrading to weak references, maintaining at least one strong reference while preserving the weak reference pattern needed to avoid memory leaks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
b70e409 to
9e971fa
Compare
Merge activity
|
CodSpeed Performance ReportMerging #733 will not alter performanceComparing Summary
Footnotes
|
…es (#733) ## Summary - Fixes #732 - "Canonicalized path was dropped" error that could occur in CI environments - Ensures canonicalized paths have at least one strong reference in the cache to prevent premature dropping - Adds comprehensive tests to prevent regression ## Problem The resolver was experiencing "Canonicalized path was dropped" errors due to weak references being used without ensuring a strong reference existed. When `canonicalize_impl` stored only weak references to canonicalized paths, if those paths weren't already in the cache, the Arc would be immediately dropped, causing the weak reference to fail on upgrade. ## Solution Modified `canonicalize_impl` in `src/cache/cache_impl.rs` to ensure canonicalized paths are added to the cache (if not already present) before downgrading to weak references. This maintains at least one strong reference while preserving the weak reference pattern needed to avoid memory leaks from circular references. ## Test Plan - [x] Added `test_canonicalized_path_not_dropped` to verify canonicalization works correctly - [x] Added `test_canonicalized_path_weak_reference` to ensure the error doesn't occur - [x] All existing tests pass, including the memory leak test - [x] `cargo test` passes - [x] `cargo clippy` passes - [x] `cargo check` passes 🤖 Generated with [Claude Code](https://claude.ai/code)
## 🤖 New release
* `oxc_resolver`: 8.0.0 -> 9.0.0 (⚠ API breaking changes)
* `oxc_napi_resolver`: 8.0.0
### ⚠ `oxc_resolver` breaking changes
```text
--- failure constructible_struct_adds_field: externally-constructible struct adds field ---
Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/constructible_struct_adds_field.ron
Failed in:
field ResolveOptions.modules in /tmp/.tmpTBvVad/oxc-resolver/src/options.rs:114
--- failure trait_method_added: pub trait method added ---
Description:
A non-sealed public trait added a new method without a default implementation, which breaks downstream implementations of the trait
ref: https://doc.rust-lang.org/cargo/reference/semver.html#trait-new-item-no-default
impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/trait_method_added.ron
Failed in:
trait method oxc_resolver::CachedPath::module_directory in file /tmp/.tmpTBvVad/oxc-resolver/src/cache.rs:69
trait method oxc_resolver::CachedPath::cached_node_modules in file /tmp/.tmpTBvVad/oxc-resolver/src/cache.rs:76
```
<details><summary><i><b>Changelog</b></i></summary><p>
## `oxc_resolver`
<blockquote>
##
[9.0.0](oxc-project/oxc-resolver@oxc_resolver-v8.0.0...oxc_resolver-v9.0.0)
- 2025-05-09
### <!-- 1 -->Bug Fixes
- hash import does not need to load from node_modules
([oxc-project#501](oxc-project#501))
### <!-- 7 -->Chore
- add `--tsconfig` to example
([oxc-project#505](oxc-project#505))
- publish `oxc_napi_resolver`
([oxc-project#496](oxc-project#496))
</blockquote>
## `oxc_napi_resolver`
<blockquote>
##
[8.0.0](https://github.com/oxc-project/oxc-resolver/releases/tag/oxc_napi_resolver-v8.0.0)
- 2025-05-09
### <!-- 0 -->Features
- *(napi)* add mimalloc
([oxc-project#423](oxc-project#423))
- [**breaking**] Rust Edition 2024
([oxc-project#402](oxc-project#402))
- expose `package_json_path`
([oxc-project#376](oxc-project#376))
- *(napi)* expose module type info in ResolveResult
([oxc-project#223](oxc-project#223))
- *(napi)* add tracing via `OXC_LOG:DEBUG`
([oxc-project#202](oxc-project#202))
- *(napi)* add async API
([oxc-project#191](oxc-project#191))
- add `imports_fields` option
([oxc-project#138](oxc-project#138))
- add more builder functions for options
([oxc-project#110](oxc-project#110))
- *(napi)* support wasi target
([oxc-project#31](oxc-project#31))
- add file_dependencies and missing_dependencies API
([oxc-project#50](oxc-project#50))
- *(napi)* expose cloneWithOptions and clearCache methods
([oxc-project#40](oxc-project#40))
- *(napi)* update the doc and type for tsconfig references
([oxc-project#24](oxc-project#24))
- *(napi)* add options
([oxc-project#19](oxc-project#19))
- *(resolver)* add tracing-subscriber feature
([oxc-project#904](oxc-project#904))
- *(resolver)* tsconfig project references
([oxc-project#862](oxc-project#862))
- *(resolver)* add thiserror
([oxc-project#847](oxc-project#847))
- *(resolver)* implement nested alias field
([oxc-project#795](oxc-project#795))
- *(resolver)* implement tsconfig-paths
([oxc-project#750](oxc-project#750))
- *(resolver)* implement configurable `exports_fields` option
([oxc-project#733](oxc-project#733))
- *(resolver)* implement `main_fields`
- *(resolver)* implement resolveToContext
([oxc-project#694](oxc-project#694))
- *(resolver)* implement restrictions (path only)
([oxc-project#693](oxc-project#693))
- *(resolver)* implement fully specified
([oxc-project#687](oxc-project#687))
- *(resolver)* imports field
([oxc-project#681](oxc-project#681))
- *(resolver)* finish most of exports field
([oxc-project#674](oxc-project#674))
- *(resolver)* port the rest of the exports field tests
([oxc-project#659](oxc-project#659))
- *(resolver)* implement symlinks
([oxc-project#582](oxc-project#582))
- *(resolver)* complete query and fragment parsing
([oxc-project#579](oxc-project#579))
- *(resolver)* add preferRelative and preferAbsolute
([oxc-project#577](oxc-project#577))
- *(resolver)* implement roots
([oxc-project#576](oxc-project#576))
- *(resolver)* implement fallback
([oxc-project#572](oxc-project#572))
- *(resolver)* implement enforceExtension
([oxc-project#566](oxc-project#566))
- *(resolver)* implement descriptionFiles option
([oxc-project#565](oxc-project#565))
- *(resolver)* implement the basics of path alias
([oxc-project#564](oxc-project#564))
- *(resolver)* accept different file system implementations
([oxc-project#562](oxc-project#562))
- *(resolver)* implement browser field
([oxc-project#561](oxc-project#561))
- *(resolver)* implement scoped packages
([oxc-project#558](oxc-project#558))
- *(resolver)* port incorrect description file test
([oxc-project#557](oxc-project#557))
- *(resolver)* implement extension_alias
([oxc-project#556](oxc-project#556))
- *(resolver)* port resolve tests
([oxc-project#555](oxc-project#555))
- *(resolver)* resolve extensions
([oxc-project#549](oxc-project#549))
- *(resolver)* add resolver test fixtures
([oxc-project#542](oxc-project#542))
### <!-- 1 -->Bug Fixes
- hash import does not need to load from node_modules
([oxc-project#501](oxc-project#501))
- *(napi)* `new ResolverFactory()` options should be optional
([oxc-project#256](oxc-project#256))
- *(napi)* update buggy NAPI-RS versions
([oxc-project#225](oxc-project#225))
- canonicalize is not supported on wasi target
([oxc-project#124](oxc-project#124))
- resolve "browser" field when "exports" is present
([oxc-project#59](oxc-project#59))
### <!-- 4 -->Refactor
- [**breaking**] remove `description_files` option
([oxc-project#488](oxc-project#488))
- [**breaking**] remove `modules` options
([oxc-project#484](oxc-project#484))
- vitest ([oxc-project#380](oxc-project#380))
- apply latest `cargo +nightly fmt`
([oxc-project#281](oxc-project#281))
- selectively parse package_json fields instead of parsing everything
([oxc-project#103](oxc-project#103))
- *(resolver)* clean up some code and tests
- *(resolver)* change internal funcs to non-pub by moving to unit tests
([oxc-project#682](oxc-project#682))
### <!-- 7 -->Chore
- publish `oxc_napi_resolver`
([oxc-project#496](oxc-project#496))
- *(napi)* make mimalloc optional to build
([oxc-project#495](oxc-project#495))
- *(README)* add wasm usage example
- *(README)* crates.io badge use recent downloads
- *(napi)* auto download wasm binding on webcontainer
([oxc-project#471](oxc-project#471))
- use root package.json for napi build
([oxc-project#469](oxc-project#469))
- *(deps)* update github-actions
([oxc-project#444](oxc-project#444))
- *(deps)* lock file maintenance npm packages
([oxc-project#436](oxc-project#436))
- bump napi
([oxc-project#404](oxc-project#404))
- *(deps)* lock file maintenance npm packages
([oxc-project#391](oxc-project#391))
- *(deps)* lock file maintenance rust crates
([oxc-project#390](oxc-project#390))
- *(README)* clarify Rust and node.js usages
- add dprint
([oxc-project#326](oxc-project#326))
- *(deps)* update napi-rs to 3.0.0-alpha
- `cargo upgrade` && `pnpm upgrade`
- *(deps)* update napi-rs to 3.0.0-alpha
- update napi changes
- *(deps)* update rust crate napi-derive to 3.0.0-alpha
- *(deps)* update rust crate napi to 3.0.0-alpha
- *(deps)* update napi-rs to 2.16.8
- *(napi)* make napi binary smaller with minimal tracing features
([oxc-project#213](oxc-project#213))
- *(napi)* remove tokio
([oxc-project#212](oxc-project#212))
- document directory is an absolute path for `resolve(directory,
specifier)`
([oxc-project#206](oxc-project#206))
- re-enable the wasi build
([oxc-project#193](oxc-project#193))
- use pnpm workspace
([oxc-project#182](oxc-project#182))
- *(deps)* update rust crates
([oxc-project#176](oxc-project#176))
- *(napi)* update NAPI-RS cli version and binding template
([oxc-project#111](oxc-project#111))
- update project github url
- *(deps)* update pnpm to v8.14.1
([oxc-project#52](oxc-project#52))
- *(deps)* update pnpm to v8.14.0
([oxc-project#48](oxc-project#48))
- *(deps)* update pnpm to v8.13.1
([oxc-project#42](oxc-project#42))
- remove FIXME comments
- *(napi)* align `*Fields` user options with enhanced-resolve
([oxc-project#35](oxc-project#35))
- *(deps)* update pnpm to v8.12.1
([oxc-project#21](oxc-project#21))
- add some doc for napi TsconfigOptions
([oxc-project#20](oxc-project#20))
- *(deps)* update pnpm to v8.12.0
([oxc-project#18](oxc-project#18))
- *(README)* adding debugging command from Rspack
- *(deps)* update pnpm to v8.11.0
([oxc-project#9](oxc-project#9))
- *(resolver)* remove tracing_subscriber
([#1362](https://github.com/oxc-project/oxc-resolver/pull/1362))
- *(resolver)* improve documentation
([oxc-project#591](oxc-project#591))
### <!-- 8 -->CI
- check for napi .d.index changes
([oxc-project#491](oxc-project#491))
- *(release-napi)* support `riscv64gc-unknown-linux-gnu` and
`s390x-unknown-linux-gnu`
([oxc-project#451](oxc-project#451))
</blockquote>
</p></details>
---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Summary
Canonicalized path was droppederror #732 - "Canonicalized path was dropped" error that could occur in CI environmentsProblem
The resolver was experiencing "Canonicalized path was dropped" errors due to weak references being used without ensuring a strong reference existed. When
canonicalize_implstored only weak references to canonicalized paths, if those paths weren't already in the cache, the Arc would be immediately dropped, causing the weak reference to fail on upgrade.Solution
Modified
canonicalize_implinsrc/cache/cache_impl.rsto ensure canonicalized paths are added to the cache (if not already present) before downgrading to weak references. This maintains at least one strong reference while preserving the weak reference pattern needed to avoid memory leaks from circular references.Test Plan
test_canonicalized_path_not_droppedto verify canonicalization works correctlytest_canonicalized_path_weak_referenceto ensure the error doesn't occurcargo testpassescargo clippypassescargo checkpasses🤖 Generated with Claude Code