Skip to content

fix(stream): honor PassThrough subclass transforms - #11028

Closed
proggeramlug wants to merge 2 commits into
mainfrom
fix/10745-passthrough-subclass
Closed

proggeramlug wants to merge 2 commits into
mainfrom
fix/10745-passthrough-subclass

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • recognize PassThrough as a native node:stream parent in class declarations and class expressions
  • initialize derived instances through a dedicated PassThrough subclass helper, preserving _transform overrides and default identity behavior
  • cover direct, aliased, dynamic, indirect, and default PassThrough inheritance paths

Fixes #10745.

Validation

  • focused HIR lowering test passes
  • focused runtime subclass initializer test passes
  • Node 26.5.1 and Perry output match byte for byte for direct import, renamed import, class expression alias, indirect subclass, and default identity cases
  • cargo fmt --all -- --check
  • git diff --check
  • scripts/check_file_size.sh
  • python3 scripts/raw_handle_debt.py --check

Summary by CodeRabbit

  • New Features

    • Added support for subclassing node:stream’s PassThrough across direct, aliased, dynamic, and indirect inheritance.
    • PassThrough subclasses now honor custom _transform implementations.
    • Subclasses without an override retain PassThrough’s default identity-transform behavior.
  • Bug Fixes

    • Prevented PassThrough subclass initialization from falling through to incorrect stream handling.
  • Tests

    • Added coverage for inheritance patterns and custom or default transform behavior.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 811bde6a-00e6-4d5a-ad86-4e7efdcd923e

📥 Commits

Reviewing files that changed from the base of the PR and between f5cfbff and 6cebdbf.

📒 Files selected for processing (18)
  • changelog.d/11028-passthrough-subclass.md
  • crates/perry-codegen/src/codegen/helpers.rs
  • crates/perry-codegen/src/codegen/method.rs
  • crates/perry-codegen/src/expr/this_super_call.rs
  • crates/perry-codegen/src/expr/write_barrier.rs
  • crates/perry-codegen/src/lower_call/new.rs
  • crates/perry-codegen/src/lower_call/new_helpers.rs
  • crates/perry-codegen/src/runtime_decls/stdlib_ffi/streams_events.rs
  • crates/perry-hir/src/lower/tests.rs
  • crates/perry-hir/src/lower/tests/issue_10745_passthrough_heritage.rs
  • crates/perry-hir/src/lower_decl/class_decl.rs
  • crates/perry-hir/src/lower_decl/class_decl/from_ast.rs
  • crates/perry-runtime/src/node_stream_constructors.rs
  • crates/perry-runtime/src/node_stream_constructors/builders.rs
  • crates/perry-runtime/src/node_stream_keepalive.rs
  • crates/perry-runtime/src/node_stream_state_tests.rs
  • crates/perry-runtime/src/object/global_this/fetch_globals.rs
  • test-files/test_gap_10745_passthrough_subclass.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

PassThrough is now recognized as a native node:stream parent. Constructor and super() paths dispatch to a dedicated runtime initializer. The initializer preserves subclass _transform callbacks and applies identity behavior when no override exists. Tests cover multiple inheritance forms.

Changes

PassThrough stream subclass support

Layer / File(s) Summary
Recognize PassThrough heritage
crates/perry-hir/src/lower_decl/*, crates/perry-hir/src/lower/tests/*
HIR class lowering recognizes PassThrough bindings as native node:stream parents for declaration and expression classes.
Route PassThrough construction
crates/perry-codegen/src/codegen/*, crates/perry-codegen/src/expr/*, crates/perry-codegen/src/lower_call/*, crates/perry-codegen/src/runtime_decls/stdlib_ffi/streams_events.rs
Code generation maps PassThrough to the passthrough kind and dispatches constructor, spread-super, fixed-arity-super, and inline-super paths to js_node_stream_passthrough_subclass_init.
Initialize PassThrough subclasses
crates/perry-runtime/src/node_stream_constructors/*, crates/perry-runtime/src/node_stream_keepalive.rs, crates/perry-runtime/src/object/global_this/fetch_globals.rs, crates/perry-runtime/src/node_stream_state_tests.rs
The runtime initializer uses Transform setup, preserves a subclass _transform callback, applies the hidden identity marker when no callback exists, supports dynamic superclass dispatch, and retains the entry point during linking.
Validate inheritance shapes
test-files/test_gap_10745_passthrough_subclass.ts, changelog.d/11028-passthrough-subclass.md
The integration test covers direct, aliased, local, indirect, expression, and default PassThrough subclasses. The changelog records override and identity behavior.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Subclass
  participant HIR
  participant Codegen
  participant Runtime
  Subclass->>HIR: extend PassThrough
  HIR->>Codegen: record native node_stream parent
  Codegen->>Runtime: invoke js_node_stream_passthrough_subclass_init
  Runtime->>Runtime: install _transform override or identity marker
  Runtime-->>Subclass: return initialized PassThrough instance
Loading

Merge Risk: ⚪ Minimal · up to 6cebd

The PassThrough initializer is retained in keepalive builds, and default subclass behavior is compared with Node output. No concrete merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 63.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 17 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: preserving transforms on PassThrough subclasses.
Description check ✅ Passed The description explains the fix, lists the main implementation areas, references issue #10745, and provides focused validation details. It does not use every template heading or checklist item, but i…
Linked Issues check ✅ Passed Issue #10745 requires HIR recognition of PassThrough as a native node:stream parent and hidden-field initialization for _transform overrides. At the reviewed head, HIR recognizes direct and alia…
Out of Scope Changes check ✅ Passed The changes remain within Issue #10745. The code changes implement native-parent recognition, codegen dispatch, FFI retention, runtime initialization, and focused HIR/runtime regression tests. The cha…
Full details: Docstring Coverage

Explanation

Docstring coverage is 63.16% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 17 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

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

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Landed on main in merge train 260 (#11085), released as v0.5.1643 at d8f24f15ed.

Cherry-picked from this PR's head 6cebdbfa2e and validated as one tree — CI 22/22 green, all 6 gap-suite shards. A train rebase gives the commits new SHAs, so GitHub cannot auto-close the source PR; closing by hand.

Nothing needed from you. Thanks.

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

Labels

None yet

Projects

None yet

1 participant