Repository navigation
fix(resolver): recover after metadata cache loss - #13014
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughMetadata resolvers recover when cached metadata disappears after a ChangesMetadata cache recovery
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Resolver
participant Registry
participant MetadataCache
Resolver->>Registry: Send conditional metadata request
Registry-->>Resolver: Return 304 Not Modified
Resolver->>MetadataCache: Load cached metadata
MetadataCache-->>Resolver: Cached body unavailable
Resolver->>Registry: Retry without validators and with no-cache
Registry-->>Resolver: Return fresh metadata
Resolver->>MetadataCache: Persist refreshed metadata
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.61338220846,
"stddev": 0.13019017271918681,
"median": 2.61135094526,
"user": 2.0862119999999997,
"system": 1.6592612599999998,
"min": 2.43350899476,
"max": 2.80586398076,
"times": [
2.72771969476,
2.43350899476,
2.5939533897600002,
2.72548877776,
2.48589330676,
2.60043929176,
2.80586398076,
2.7048914597600002,
2.43380058976,
2.62226259876
]
},
{
"command": "pacquet@main",
"mean": 2.6451459245600004,
"stddev": 0.15038290155293574,
"median": 2.60361489626,
"user": 2.3680903,
"system": 1.86801096,
"min": 2.45698240976,
"max": 2.9361423437600003,
"times": [
2.83540199776,
2.45698240976,
2.69636357076,
2.54031798476,
2.50958876776,
2.9361423437600003,
2.70556634376,
2.56386603476,
2.57569743876,
2.63153235376
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5723159460600002,
"stddev": 0.1389274645590798,
"median": 1.54931164376,
"user": 1.6255115,
"system": 1.5633002599999999,
"min": 1.42919329076,
"max": 1.80458037076,
"times": [
1.70614078376,
1.43518712476,
1.60455511676,
1.4547777797600001,
1.73367813576,
1.42919329076,
1.4528706577600001,
1.49406817076,
1.60810802976,
1.80458037076
]
},
{
"command": "pnpr@main",
"mean": 1.5361176745599998,
"stddev": 0.1645113757134952,
"median": 1.4689241822599999,
"user": 1.5493190000000001,
"system": 1.5079239599999998,
"min": 1.40022337576,
"max": 1.8335889067600002,
"times": [
1.41168809576,
1.40022337576,
1.81739941176,
1.8335889067600002,
1.40184656976,
1.58116100676,
1.46008905676,
1.42437216576,
1.55304884876,
1.47775930776
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.28690069266,
"stddev": 0.013662645674005441,
"median": 0.28339627225999997,
"user": 0.23208886,
"system": 0.56684768,
"min": 0.26972631376,
"max": 0.30888988076,
"times": [
0.28748822176,
0.30888988076,
0.29735766776,
0.27802509376,
0.30695677276,
0.27700820276000004,
0.27930432276,
0.28952910276000005,
0.27472134776,
0.26972631376
]
},
{
"command": "pacquet@main",
"mean": 0.27782760346,
"stddev": 0.017066327713884045,
"median": 0.28016113726,
"user": 0.22778826,
"system": 0.55318168,
"min": 0.25395235776,
"max": 0.30449643476000005,
"times": [
0.25592967676,
0.27534132976000003,
0.28498094476,
0.28796681676,
0.27188244176000004,
0.25395235776,
0.26123597376,
0.28738980476000003,
0.29510025376000004,
0.30449643476000005
]
},
{
"command": "pnpr@HEAD",
"mean": 0.32089179075999996,
"stddev": 0.0149916834053399,
"median": 0.31428415426,
"user": 0.25925876,
"system": 0.60047348,
"min": 0.30593914976000003,
"max": 0.35564852676,
"times": [
0.31190865576000004,
0.32637694176000004,
0.32746509776000005,
0.30593914976000003,
0.33222918376000005,
0.31038578176000003,
0.31490078076,
0.31039626176,
0.31366752776,
0.35564852676
]
},
{
"command": "pnpr@main",
"mean": 0.28893681396,
"stddev": 0.016004279727042783,
"median": 0.29059867976000003,
"user": 0.23224155999999999,
"system": 0.55477938,
"min": 0.26315069676,
"max": 0.30794084776,
"times": [
0.29899967676,
0.27585097976,
0.27889312276,
0.27194991376,
0.26315069676,
0.28585882376000005,
0.29533853576,
0.30794084776,
0.30407342976,
0.30731211276000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.9578245891600004,
"stddev": 0.031125188840513816,
"median": 2.95273815656,
"user": 2.6040414800000002,
"system": 1.9100996999999995,
"min": 2.91519371956,
"max": 3.0098599895600002,
"times": [
3.0007385385600003,
2.9603863675600004,
3.0098599895600002,
2.94854037656,
2.94804207056,
2.91919569956,
2.94145548556,
2.97789770756,
2.91519371956,
2.9569359365600003
]
},
{
"command": "pacquet@main",
"mean": 3.0187217450599997,
"stddev": 0.07828441598455942,
"median": 3.03236299706,
"user": 2.7858529800000005,
"system": 1.8885336000000001,
"min": 2.8771074975600004,
"max": 3.11039485656,
"times": [
3.05288024656,
2.9695605025600003,
2.8771074975600004,
2.99282427656,
2.92346302356,
3.08988983056,
3.0435313655600003,
3.02119462856,
3.10637122256,
3.11039485656
]
},
{
"command": "pnpr@HEAD",
"mean": 1.74650319256,
"stddev": 0.13641150881093142,
"median": 1.7955709795600001,
"user": 1.7916469799999994,
"system": 1.7356702,
"min": 1.52874102056,
"max": 1.88647648756,
"times": [
1.88647648756,
1.8085282065600001,
1.5927091665600002,
1.52874102056,
1.8625052875600001,
1.84659942556,
1.83849909656,
1.78261375256,
1.5485755485600001,
1.76978393356
]
},
{
"command": "pnpr@main",
"mean": 1.7981267137600003,
"stddev": 0.14984035988767702,
"median": 1.76227077306,
"user": 1.8502471799999998,
"system": 1.8324076999999996,
"min": 1.59447498356,
"max": 2.02588004556,
"times": [
1.73064815056,
2.02588004556,
1.7319412465600001,
1.8923686435600002,
1.67990479356,
1.6317255855600001,
1.9866103445600003,
1.79260029956,
1.91511304456,
1.59447498356
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.9994037751799999,
"stddev": 0.13269998254640578,
"median": 1.00895883068,
"user": 1.2237065,
"system": 0.9512110999999999,
"min": 0.76913541618,
"max": 1.1827567721799999,
"times": [
1.13876903818,
0.9982607791800001,
1.0340539491799998,
1.01690669618,
1.1827567721799999,
1.08733959218,
0.76913541618,
1.0010109651799999,
0.79337499018,
0.97242955318
]
},
{
"command": "pacquet@main",
"mean": 0.7797538376800001,
"stddev": 0.0638720157557281,
"median": 0.7791665671800001,
"user": 0.9842944000000001,
"system": 0.9122523000000001,
"min": 0.68343262518,
"max": 0.8555922221800001,
"times": [
0.8555922221800001,
0.83153994218,
0.84189933118,
0.8450928831800001,
0.7860290291800001,
0.7562209641800001,
0.77230410518,
0.73758299118,
0.68784428318,
0.68343262518
]
},
{
"command": "pnpr@HEAD",
"mean": 0.37349796207999997,
"stddev": 0.046109492349114184,
"median": 0.36288256318,
"user": 0.2630639,
"system": 0.5962132,
"min": 0.31547192118,
"max": 0.44840037718000003,
"times": [
0.37331702518000004,
0.35244810118000003,
0.38904286618000006,
0.33343703218000004,
0.33941341918,
0.31547192118,
0.33558913018000003,
0.43347271718,
0.44840037718000003,
0.41438703118000003
]
},
{
"command": "pnpr@main",
"mean": 0.38316382958000006,
"stddev": 0.03556336282932487,
"median": 0.38378931168,
"user": 0.25527079999999996,
"system": 0.6631273999999999,
"min": 0.33419471618,
"max": 0.44374690718000004,
"times": [
0.44374690718000004,
0.36083713118000005,
0.33966463818000003,
0.33419471618,
0.37830236818,
0.39270924018000003,
0.38927625518000003,
0.42948087518000005,
0.39935170518,
0.36407445918000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.1087113766199996,
"stddev": 0.049511394143986844,
"median": 2.10256922662,
"user": 1.40355896,
"system": 1.07913278,
"min": 2.01666590362,
"max": 2.19467896362,
"times": [
2.09712095262,
2.15238207262,
2.12621921162,
2.01666590362,
2.19467896362,
2.09696523062,
2.0576201096199997,
2.10634999262,
2.1403228686199998,
2.09878846062
]
},
{
"command": "pacquet@main",
"mean": 2.12414133682,
"stddev": 0.09461136087714224,
"median": 2.1718699711199996,
"user": 1.4381370599999999,
"system": 1.04797988,
"min": 1.93910382962,
"max": 2.22713017962,
"times": [
2.07358417362,
2.17487672462,
2.16886321762,
2.19450236862,
2.1776666316199997,
2.17695712062,
2.22713017962,
2.11856470462,
1.99016441762,
1.93910382962
]
},
{
"command": "pnpr@HEAD",
"mean": 0.36403465132,
"stddev": 0.01916998403848161,
"median": 0.36826182762000004,
"user": 0.25006736,
"system": 0.6502108799999999,
"min": 0.33439593062000006,
"max": 0.38891072162000007,
"times": [
0.37938349462000004,
0.34909414562,
0.33741683062000005,
0.38712753962000007,
0.36859184362,
0.38891072162000007,
0.36980536262,
0.35768883262000006,
0.33439593062000006,
0.36793181162000005
]
},
{
"command": "pnpr@main",
"mean": 0.33965282482000003,
"stddev": 0.021710252066931193,
"median": 0.33615321162,
"user": 0.22804626,
"system": 0.59718708,
"min": 0.30530975362000007,
"max": 0.36970603762000004,
"times": [
0.35868718162,
0.36306634562000006,
0.36970603762000004,
0.32209516362000007,
0.32803635262,
0.32386214862000007,
0.30530975362000007,
0.35706627062000007,
0.34427007062000003,
0.32442892362000003
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.39420317762,
"stddev": 0.015346041301524527,
"median": 0.39086222832000006,
"user": 0.3687985199999999,
"system": 0.10933384000000002,
"min": 0.37492771232000005,
"max": 0.41728170632000006,
"times": [
0.41728170632000006,
0.40512927632000006,
0.39188786932,
0.40784279832000003,
0.37492771232000005,
0.38191923132000005,
0.38983658732000004,
0.38333453532000006,
0.37739460332,
0.41247745632000005
]
},
{
"command": "pacquet@main",
"mean": 0.38885653832000006,
"stddev": 0.01225774011771924,
"median": 0.39113164082000007,
"user": 0.37352051999999997,
"system": 0.09675653999999999,
"min": 0.36824491232000006,
"max": 0.40723853932000004,
"times": [
0.40723853932000004,
0.39619032332000004,
0.39550913132000004,
0.40191496732000004,
0.36824491232000006,
0.37523938632000003,
0.38129057632,
0.39183743832000006,
0.39042584332,
0.38067426532000004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09081017488666668,
"stddev": 0.004606802667069082,
"median": 0.09004499182,
"user": 0.019698786666666666,
"system": 0.014473473333333335,
"min": 0.08298463432,
"max": 0.10546711032,
"times": [
0.09163768432000001,
0.08866122632000001,
0.08962183032000001,
0.09107437932000001,
0.08946171132000001,
0.08920157932,
0.09071881632,
0.08859932832,
0.08298463432,
0.08703331832000001,
0.08477589832,
0.08582313832,
0.09989070432000001,
0.10546711032,
0.10111253932000001,
0.08834623632000001,
0.09032737332,
0.09199673532000001,
0.09241666232000001,
0.08593946332,
0.09446650832,
0.08894935732,
0.09169055432,
0.08976261032,
0.09108478532,
0.09254728732,
0.08952991032,
0.09080003932000001,
0.09087931232,
0.08950451232000001
]
},
{
"command": "pnpr@main",
"mean": 0.09543093711999999,
"stddev": 0.005741446318428109,
"median": 0.09380767332,
"user": 0.02383812,
"system": 0.013822539999999998,
"min": 0.08699764932000001,
"max": 0.11224135332000001,
"times": [
0.09337347832000001,
0.08823937232000001,
0.09791069332,
0.09808565332000001,
0.09223017332000001,
0.09347284532000001,
0.10324704232000001,
0.10571609632000001,
0.10010628832000001,
0.09373163332000001,
0.09123176532,
0.09579673032000001,
0.09642662932000001,
0.09182160632000001,
0.08699764932000001,
0.09388371332,
0.09986671932,
0.09906319932,
0.09442238332000001,
0.11224135332000001,
0.10054982532000001,
0.08924200432000001,
0.09163005332,
0.09059277932000001,
0.10095766232,
0.08969282632,
0.08822586632000001,
0.09980515132000001,
0.09300972232,
0.09135719732000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.61250227038,
"stddev": 0.05681569630210078,
"median": 4.59258991838,
"user": 2.6440478,
"system": 2.0264215,
"min": 4.54174345688,
"max": 4.69772853788,
"times": [
4.69772853788,
4.5556999218800005,
4.65673444088,
4.67360927788,
4.54174345688,
4.57484879888,
4.56817269588,
4.60333885788,
4.67130573688,
4.58184097888
]
},
{
"command": "pacquet@main",
"mean": 4.69780039388,
"stddev": 0.1639134166348344,
"median": 4.70101894738,
"user": 2.5858162,
"system": 1.9521903000000003,
"min": 4.5080117918800005,
"max": 4.92740694888,
"times": [
4.75877590488,
4.6477573558800005,
4.92740694888,
4.75428053888,
4.51339040988,
4.5080117918800005,
4.5320823718800005,
4.84856133488,
4.91002268288,
4.57771459888
]
},
{
"command": "pnpr@HEAD",
"mean": 3.57600110198,
"stddev": 0.09534097698636838,
"median": 3.55709753988,
"user": 1.5571181999999997,
"system": 1.4356554,
"min": 3.48224163088,
"max": 3.78059453988,
"times": [
3.48468635588,
3.48224163088,
3.65485761088,
3.51830802088,
3.5241064048800004,
3.59008867488,
3.4940224838800003,
3.59921377688,
3.63189152088,
3.78059453988
]
},
{
"command": "pnpr@main",
"mean": 3.67335192548,
"stddev": 0.11205944491872386,
"median": 3.66309532088,
"user": 1.7956933,
"system": 1.737307,
"min": 3.5270573038800004,
"max": 3.81138612288,
"times": [
3.5366058538800003,
3.80948292288,
3.65717269888,
3.56297057688,
3.5270573038800004,
3.66901794288,
3.61759557988,
3.81138612288,
3.75321917188,
3.78901108088
]
}
]
} |
|
| Branch | pr/13014 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,527.20 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 361.15 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 340.74 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 86.38 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,513.80 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,638.31 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 275.55 ms |
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? |
Confidence Score: 5/5Safe to merge. The recovery logic is bounded (one bypass retry, no recursion), both implementations follow the same pattern, and the tests cover all four observable outcomes of the new path. The change is a single, well-contained error-recovery addition to two parallel code paths (TypeScript and Rust). The AtomicBool in Rust correctly propagates bypass state across body-read retries. In TypeScript, fetchMetadataFromFromRegistry correctly rejects a bypass 304 before returning, so the notModified guard in callers is a type-narrowing safety check rather than a reachable production path. The outer try/catch in pickPackage correctly rethrows when the mirror is gone. No files require special attention. Reviews (9): Last reviewed commit: "refactor(resolver): rename metaCachedInS..." | Re-trigger Greptile |
Remove the pacquet `CacheMissingAfter304` variant, orphaned when the cache-loss recovery replaced its only construction site. It advertised `ERR_PNPM_CACHE_MISSING_AFTER_304` as reachable while the TypeScript CLI had dropped its equivalents outright, so the two stacks disagreed on a public error code. A `pub` enum variant draws no dead-code warning, so nothing flagged it. Collapse the four hand-copied `META_NOT_MODIFIED_WITHOUT_CACHE` constructions into `notModifiedWithoutCacheError`, and state at the recovery call sites why a bypass request can only come back with a body or an error. The guards that remain are type narrowing over the fetcher's union return, not a claim that a bypassed 304 is reachable. Drop the caller-side nulling of `etag`/`modified` in the cached fetcher: `send_metadata_request` already forces both to `None` before computing `has_validator`, so the conditional was a third expression of the same fact. Changeset now names `ERR_PNPM_CACHE_MISSING_AFTER_304`, the error users search for when they hit this.
65ce0d2 to
0cd9655
Compare
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
PR Code Suggestions ✨Latest suggestions up to 744047a Warning
Previous suggestionsSuggestions
|
||||||||||||||||||||||
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13014 +/- ##
==========================================
+ Coverage 85.45% 85.49% +0.04%
==========================================
Files 501 502 +1
Lines 80654 80859 +205
==========================================
+ Hits 68924 69134 +210
+ Misses 11730 11725 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… use The helper sat above the interfaces at the top of fetch.ts while its only in-file call site is inside fetchMetadataFromFromRegistry. Move it below that function, next to the other helpers it sits with, so the file keeps reading top-down from entry point to detail.
|
Code review by qodo was updated up to the latest commit 1b46b8c |
PR Code Suggestions ✨Warning
|
|||||||||||
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
…rd clauses fetchMetadataCached threaded one reassigned `result` through a two-level nested 304 branch, so the persist-and-return at the bottom could hold either the conditional fetch or the cold retry. Give each fetch its own name, turn the 304 handling into top-down guard clauses, and name the shared persist-a-fresh-body step once. Behavior is unchanged; the cache-race tests cover every exit.
|
Code review by qodo was updated up to the latest commit 744047a |
Convert persistAndReturn, serveValidatedMeta, and persistFreshMeta from const arrow closures to hoisted function declarations placed after their call sites, matching the repo convention (functions are declared after they are used) that already governs the module-level helpers here. They still close over the same enclosing scope, so behavior is unchanged.
|
Code review by qodo was updated up to the latest commit d6aea76 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
The pkgMirror-null and cache-bypass-refetch 304 branches in fetchMetadataCached are unreachable: fetchMetadataFromFromRegistry only resolves notModified after sending a validator, and rejects a validator-less 304 itself. Per the repo convention — PnpmError is for user-reachable errors, while type-guard and unreachable-branch errors stay plain Error — throw plain Error there. The user-facing ERR_PNPM_META_NOT_MODIFIED_WITHOUT_CACHE still surfaces from fetch.ts on the reachable path, and pickPackage keeps the PnpmError because its injected fetch can reach the branch (a test asserts the code). Also trim call-site comments that restated a guard or duplicated the helper's own doc.
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
|
Code review by qodo was updated up to the latest commit 0226ed7 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
The on-disk mirror meta reads more clearly as diskMeta, and the shorter name declutters pickPackage's fast paths. It stays distinct from cachedMeta, the in-memory metaCache hit, so the disk-vs-memory contrast the old name carried is preserved.
|
Code review by qodo was updated up to the latest commit 8cba06f |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Summary
Recover when a registry responds with
304 Not Modifiedafter the corresponding metadata cache entry has disappeared.Both the TypeScript resolver and pacquet now retry the request once without cache validators, then reuse their existing metadata normalization and persistence paths. The retry remains bounded and does not recursively fall back to stale app metadata.
Regression tests cover the picker path, the cached full-metadata helper, the absence of conditional headers on the retry, and preservation of the bypass state across Rust body and decoding retries.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Codex, GPT-5).
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit