Skip to content

fix(compile): auto-optimize archives-fresh fast-path drops non-tokio routed ext staticlibs#5668

Merged
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/autoopt-freshpath-nontokio-libs
Jun 25, 2026
Merged

fix(compile): auto-optimize archives-fresh fast-path drops non-tokio routed ext staticlibs#5668
proggeramlug merged 1 commit into
PerryTS:mainfrom
proggeramlug:fix/autoopt-freshpath-nontokio-libs

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Problem

When the auto-optimized archives are already fresh, the fast-path in optimized_libs/driver.rs returned:

let well_known_libs = resolve_auto_well_known_libs(&workspace_root, &release_dir, &tokio_using_bindings, target, format);
return OptimizedLibs { /* ... */ well_known_libs, prefer_well_known_before_stdlib: false };

resolve_auto_well_known_libs only resolves the tokio-using routed bindings. The non-tokio routed well-known ext staticlibs collected earlier in the same call (CPU-only wrappers like the compression crate that node:zlib flips to, events, …) were silently dropped from well_known_libs.

Result: a program importing node:zlib (or another non-tokio well-known) fails to link with undefined js_ext_zlib_* / js_zlib_* symbols — even though the routed .a is on disk and was logged as routed. Only the non-fresh (full-rebuild) path linked correctly, so this surfaced intermittently depending on archive freshness.

Fix

Merge the outer well_known_libs (the non-tokio routed libs gathered by the routing loop) into the fresh-path return instead of replacing it with the tokio-only set, and set prefer_well_known_before_stdlib accordingly. The full-rebuild path already carried these libs.

let mut well_known_libs = well_known_libs;
well_known_libs.extend(resolve_auto_well_known_libs(/* tokio libs */));
return OptimizedLibs { /* ... */ prefer_well_known_before_stdlib: !well_known_libs.is_empty(), well_known_libs };

Summary by CodeRabbit

  • Bug Fixes
    • Improved library selection in the fast path for optimized builds, so previously detected CPU-only libraries are now retained instead of being dropped.
    • Better handling of well-known libraries when auto-detected libraries are added, helping preserve the expected build order and library preference.

…esh link path

The auto-optimize 'archives fresh' fast-path returned only the tokio-using
routed libs (resolve_auto_well_known_libs), dropping the non-tokio routed
well-known ext staticlibs (e.g. the compression wrapper for node:zlib) collected
by the routing loop. The link then failed with undefined js_ext_zlib_*/js_zlib_*
even though the .a was on disk. Merge the routed libs into the fresh-path return;
the full-rebuild path already included them.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e42a1a33-119b-4a27-86a2-ec49a85535fd

📥 Commits

Reviewing files that changed from the base of the PR and between e68b493 and fdc7b82.

📒 Files selected for processing (1)
  • crates/perry/src/commands/compile/optimized_libs/driver.rs

📝 Walkthrough

Walkthrough

The fresh-archive path now keeps previously collected CPU-only well-known libraries, adds auto-resolved Tokio-using libraries, and sets the stdlib preference flag from whether any well-known libraries remain.

Changes

Fresh-archive well-known library handling

Layer / File(s) Summary
Merge well-known libraries
crates/perry/src/commands/compile/optimized_libs/driver.rs
The fresh-archive branch extends well_known_libs with auto-resolved Tokio-using libraries and sets prefer_well_known_before_stdlib based on the merged collection.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 I hopped through fresh archives with glee,
Kept well-known libs safe as can be.
Tokio joined the bun,
And the stdlib stayed in order for me.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the bug and fix, but it omits the template's Summary, Changes, Related issue, Test plan, and Checklist sections. Add the missing template sections, especially Summary, bulletized Changes, Related issue, and Test plan, and include the checklist items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main fix in the archives-fresh fast-path.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant