Registry Mirror
Skip to content

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Fixes #9719 — a bug I found while validating an unrelated PR, filed, and have now fixed.

The break

Any program importing node:http failed to link from a cold auto-optimize cache:

Undefined symbols: _js_bun_http_response_snapshot_json,
  referenced from perry_ext_http::server::bun_server::settle_value

perry-ext-http's server/bun_server.rs declares that symbol and js_bun_http_request_from_json in an unconditional extern "C" block — only its #[cfg(test)] arm stubs them. Their definitions live in fetch::bun_server_bridge, which perry-stdlib compiles only under web-fetch. The auto-optimize feature set for a node:http program is async-runtime, external-http-{client,server}-pump, external-net-tls, external-tls-server, external-ws-pump — no web-fetch. Definition and reference disagreed about the feature gating them.

Why nothing caught it

Plain cargo build / cargo test never link the auto-optimize ext-http path, and any warm target/perry-auto-* cache hides it from a manual check. It surfaced only in a full gap sweep from a cold cache, where it accounted for eight compile_fail results.

The fix, and the two alternatives rejected

The definitions genuinely need Fetch machinery (FETCH_RESPONSES, consume_response_body), so they cannot move out of the gated module. Making the http features depend on web-fetch would link reqwest — an HTTP client — into every node:http server build, which is a large widening for two small bridge functions.

Instead perry-stdlib defines both symbols in every configuration: the real bridge under web-fetch, and under cfg(not(web-fetch)) a pair answering "nothing to bridge" (null / undefined). That is the correct answer rather than a placeholder — with no fetch module there are no Response objects to snapshot, and it is what the real bridge already returns for an unknown handle.

Validation

Both feature configurations compile — no missing symbol without web-fetch, no duplicate definition with it.

All eight previously-failing gap tests now compile, link and pass against the pinned node 26.5.1: test_gap_3527_http_ctor_prototype, test_gap_gc_http2_pending_event_callback_rooting, test_gap_http_client_no_redirect_follow, test_gap_http_overloads_3226plus, test_gap_http_req_async_iterator, test_gap_http_res_socket_writable_onfinished, test_gap_http2_settings, test_gap_regex_replace_dyn_regex_with_http. test_gap_3527's output is byte-identical to node's.

64/64 lint gates; perry-stdlib 130 passed, 0 failed.

On regression coverage: I wrote a crates/perry-stdlib/tests/ symbol-existence test and then deleted it. An integration test links against the rlib under -dead_strip, which removes #[no_mangle] symbols nothing references — so it failed to link while the real fix worked, testing the harness rather than the property. The eight gap tests are the real coverage: they exercise the cold auto-optimize link that no unit test reaches, which is exactly the path that broke.

@proggeramlug
proggeramlug merged commit 6dcd1a5 into main Sep 4, 2026
@proggeramlug
proggeramlug deleted the train123 branch September 4, 2026 16:24
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.

node:http fails to link from a cold auto-optimize cache: js_bun_http_response_snapshot_json is web-fetch-gated but referenced unconditionally

1 participant