Skip to content

stream: construct correct prototype to transferred streams - #55047

Closed
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:stream-wpt
Closed

stream: construct correct prototype to transferred streams#55047
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:stream-wpt

Conversation

@avivkeller

Copy link
Copy Markdown
Member

Fixes#54603
Ref #50107

@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. web streams labels Sep 21, 2024
@avivkelleravivkeller 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
Copy Markdown
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.

@avivkelleravivkellerSep 21, 2024

Copy link
Copy Markdown
MemberAuthor

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.

@avivkelleravivkellerSep 21, 2024

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
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?

@codecov

codecovBot commented Sep 21, 2024

Copy link
Copy Markdown

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 linesCoverage Δ
lib/internal/webstreams/readablestream.js98.31% <100.00%> (-0.01%)⬇️
lib/internal/webstreams/transformstream.js99.56% <100.00%> (-0.01%)⬇️
lib/internal/webstreams/writablestream.js99.85% <100.00%> (-0.01%)⬇️

... and 36 files with indirect coverage changes

@avivkeller

Copy link
Copy Markdown
MemberAuthor

Superseded by #55067

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

Labels

needs-benchmark-ciPR that need a benchmark CI run.needs-ciPRs 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

@avivkeller@MattiasBuelens@anonrig@nodejs-github-bot