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

Fixed OutgoingMessage so that it inherits from stream.Writable instead of stream #45834

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zeazad-hub
Copy link

http: fixed OutgoingMessage so that it inherits from stream.Writable instead of stream

http.OutgoingMessage is supposed to be an instance of stream.Writable, so I set
the prototype of OutgoingMessage equal to the Writable prototype and I called
the Writable consrtuctor at the end of the constructor for OutgoingMessage. I
made sure to override any methods and prpoperties in Writable that were
already defined in OutgoingMessage in order to not interfere with the
current behavior of OutgoingMessage. Note that I have recently
been told that this change does lead to performance issues with http.OutgoingMessage.

Fixes: #44188

… instead of stream

http.OutgoingMessage is supposed to be an instance of stream.Writable, so I set
the prototype of OutgoingMessage equal to the Writable prototype and I called
the Writable consrtuctor at the end of the constructor for OutgoingMessage. I
made sure to override any methods and prpoperties in Writable that were
already defined in OutgoingMessage in order to not interfere with the
current behavior of OutgoingMessage.

Fixes: nodejs#44188
… instead of stream

http.OutgoingMessage is supposed to be an instance of stream.Writable, so I set
the prototype of OutgoingMessage equal to the Writable prototype and I called
the Writable consrtuctor at the end of the constructor for OutgoingMessage. I
made sure to override any methods and prpoperties in Writable that were
already defined in OutgoingMessage in order to not interfere with the
current behavior of OutgoingMessage.

Fixes: nodejs#44188
I accidentally left a script.sh file that copied all of the
test files into a different directory in a previous commit.
I did not end up using the script.sh and have now removed it
from the repo.

Fixes: nodejs#44188
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net
  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Dec 12, 2022
@@ -0,0 +1,13 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you forgot to remove this file

@@ -53,6 +53,7 @@ const {
getHighWaterMark,
getDefaultHighWaterMark
} = require('internal/streams/state');

Copy link
Contributor

Choose a reason for hiding this comment

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

These newline only file changes should be removed (including the one in the test file).

assert.strictEqual(isWritable, true);


const b = typeof nodeStreamResponse?._writableState
Copy link
Contributor

Choose a reason for hiding this comment

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

This and other lines won't pass the linter. Make sure you run make test locally to make sure all other tests pass in addition to the linting.

@mscdex
Copy link
Contributor

mscdex commented Dec 12, 2022

I think an immediate concern here is about compatibility with userland.

At the very least a citgm will be needed and even then I'd be very wary of making a change like this.

@mscdex mscdex added needs-citgm PRs that need a CITGM CI run. needs-benchmark-ci PR that need a benchmark CI run. labels Dec 12, 2022
@ronag
Copy link
Member

ronag commented Dec 13, 2022

We have tried to do this multiple times in the past but the performance regression was significant. So unless V8 has implemented some magic since then I don't think we can do this.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

I have a feeling this will not be possible because:

  1. Express and many other frameworks rely on this specific internal structure.

  2. performance of http would be crippled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem. needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. needs-citgm PRs that need a CITGM CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http.ServerResponse is not an instance of stream.Writable?
5 participants