Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: construct correct prototype to transferred streams #55047

Closed
wants to merge 1 commit into from

Conversation

RedYetiDev
Copy link
Member

Fixes #54603
Ref #50107

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. web streams labels Sep 21, 2024
@RedYetiDev RedYetiDev added the needs-benchmark-ci PR that need a benchmark CI run. label Sep 21, 2024
stream.constructor = ReadableStream;

return stream;
return ReflectConstruct(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReflectConstruct is extremely slow.

Copy link
Member Author

@RedYetiDev RedYetiDev Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware, is there another way to make this WPT compliant? We need a way to have the prototype of the transferred stream === the original prototype.

Copy link
Member Author

@RedYetiDev RedYetiDev Sep 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW regarding speed, this has around a -20% on speed, so not good. Is there a reason we can't just return ReadableStream as is?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deno solves this by adding a special overload to their ReadableStream constructor, which essentially skips the regular steps. Maybe we should do something similar?

Copy link

codecov bot commented Sep 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.22%. Comparing base (5116578) to head (fe71574).
Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55047      +/-   ##
==========================================
- Coverage   88.24%   88.22%   -0.02%     
==========================================
  Files         652      652              
  Lines      183886   183867      -19     
  Branches    35855    35859       +4     
==========================================
- Hits       162263   162221      -42     
- Misses      14902    14919      +17     
- Partials     6721     6727       +6     
Files with missing lines Coverage Δ
lib/internal/webstreams/readablestream.js 98.31% <100.00%> (-0.01%) ⬇️
lib/internal/webstreams/transformstream.js 99.56% <100.00%> (-0.01%) ⬇️
lib/internal/webstreams/writablestream.js 99.85% <100.00%> (-0.01%) ⬇️

... and 36 files with indirect coverage changes

@RedYetiDev RedYetiDev closed this Sep 22, 2024
@RedYetiDev
Copy link
Member Author

Superseded by #55067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. web streams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node.js structuredClone objects do not preserve prototypes
4 participants