Skip to content

hotfix: remove unresolved conflict markers from #3818/#3829 merges - #3863

Merged
proggeramlug merged 1 commit into
mainfrom
hotfix-conflict-markers
May 31, 2026
Merged

proggeramlug merged 1 commit into
mainfrom
hotfix-conflict-markers

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Closes #3285

Implementation

zlib deflate-family streams expose stream.params(level, strategy, cb). Perry previously treated it as a no-op callback shim (zlib_stream_params in perry-stdlib), so it neither validated arguments nor changed compression behavior. Because the well-known binding routes node:zlib to perry-ext-zlib (and strips the bundled compression feature), the observable path lives in perry-ext-zlib, which had no params dispatch arm at all (it fell through to undefined).

  • perry-runtime (node_submodules/zlib.rs): new js_zlib_validate_params(level, strategy) -> i32 helper, a sibling of the existing js_zlib_resolve_level. It validates the args exactly like Node — non-numeric level/strategy throws TypeError [ERR_INVALID_ARG_TYPE], level outside -1..=9 or strategy outside 0..=4 throws RangeError [ERR_OUT_OF_RANGE] (level validated first) — and returns the clamped flate2 level (Z_DEFAULT_COMPRESSION / -1 → default 6). The ext crate can't reach Perry's numeric typing or the js_throw machinery, so it calls back here (same pattern as #2935). Added a #[used] keepalive anchor so auto-optimize's whole-program bitcode rebuild doesn't dead-strip the codegen/ext-only symbol.
  • perry-ext-zlib (stream.rs): new params dispatch arm + stream_params(). It validates first (the validate call may js_throw/longjmp, so it must run before taking the registry lock to avoid poisoning the mutex), then retunes by rebuilding the deflate-family encoder at the new level when no data has been written yet (the common case — params() before the first write), since flate2 exposes no mid-stream deflateParams. After data is written it validates + flushes only. The callback is queued and fired by the existing pump. Also extracted make_codec_state_with_level() and wired the initial createDeflate({ level }) option through it (previously the factory ignored _opts), and added a wrote_data flag. params was already in the routed-method allowlist in perry-stdlib's dispatch, so no dispatch wiring change was needed.

No new HIR variant. No manifest/API surface change (both FFIs are internal symbols), so no docs regen.

Validation

test-files/test_gap_zlib_3285_params.ts — byte-identical to node --experimental-strip-types under the DEFAULT auto-optimize compile:

badLevel: ERR_OUT_OF_RANGE
badStrategy: ERR_OUT_OF_RANGE
badType: ERR_INVALID_ARG_TYPE
level0Bigger: true
rt0: 32768
rt9: 32768

params(0, …) and params(9, …) produce different valid deflate output for a 32768-byte repeated input (level 0 > level 9), both inflateSync round-trip back to 32768 bytes, the success callback fires, and invalid level/strategy/type throw Node-compatible errors synchronously. cargo fmt --all -- --check clean, ./scripts/check_file_size.sh exit 0, cargo test --release -p perry-ext-zlib -p perry-hir all green.

Admin-merges of #3818 and #3829 landed nested git conflict markers in
four files, leaving main uncompilable. Restore those files to their last
marker-free state (93425ba, #3823). #3855/#3856/#3858 did not touch them.

The node-compat surface from #3818 (crypto legacy) and #3829
(constants.default alias) is reverted on these files and needs redoing
from clean branches; the original fork branches carry committed markers.
@proggeramlug
proggeramlug merged commit 21246c8 into main May 31, 2026
7 of 11 checks passed
@proggeramlug
proggeramlug deleted the hotfix-conflict-markers branch May 31, 2026 20:16
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:zlib: make stream.params retune compression level and strategy

1 participant