GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: Make OutgoingMessage more streamlike by ronag · Pull Request #45672 · nodejs/node

Conversation

@ronag

@ronag ronag commented Nov 29, 2022

Copy link
Copy Markdown
Member

Implement missing getters error & closed. Add support for proper "writable" check through isWritable helper.

We cannot fix the OutgoingMessage.writable propery as that will break the ecosystem.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@ronag
ronag requested a review from aduh95 November 29, 2022 10:43
@nodejs-github-bot

nodejs-github-bot commented Nov 29, 2022

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net
  • @nodejs/streams
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added http Issues and PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Nov 29, 2022
@ronag
ronag requested a review from mcollina November 29, 2022 10:45
@ronag
ronag force-pushed the outgoing-writable-12 branch 3 times, most recently from 0af46f6 to ca3ed8a Compare November 29, 2022 10:46
@ronag
http: Make OutgoingMessage more streamlike
1047db4
Implement missing getters error & closed. Add support for
proper "writable" check through isWritable helper.

We cannot fix the OutgoingMessage.writable propery as that
will break the ecosystem.
@ronag
ronag force-pushed the outgoing-writable-12 branch from ca3ed8a to 1047db4 Compare November 29, 2022 10:46
aduh95
aduh95 reviewed Nov 29, 2022
View reviewed changes
Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag added 4 commits November 29, 2022 13:13
@ronag
fixup
7813900
@ronag
fixup
8d247a5
@ronag
fixuP
e0a4a31
@ronag
fixuP
c9a76ba
@ShogunPanda

ShogunPanda commented Nov 29, 2022

Copy link
Copy Markdown
Contributor

The changes LGTM. Are you going to add any test?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ronag
fixup: tests
2a412af
@ronag ronag added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. author ready PRs with CI started, the required approvals, and no outstanding review comments. and removed needs-ci PRs that need a full CI run. labels Nov 29, 2022
ronag added 2 commits November 29, 2022 16:25
@ronag
fiuxp
3b3fbb5
@ronag
fiuxp
25d952b
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 29, 2022
@nodejs-github-bot

nodejs-github-bot commented Nov 29, 2022

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/48234/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Nov 30, 2022
CI Reliability 2022-11-30 nodejs/reliability#444
Open
15 tasks
mcollina
mcollina approved these changes Nov 30, 2022
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
aduh95
aduh95 reviewed Nov 30, 2022
View reviewed changes

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

There are seemingly related test failures.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread lib/_http_outgoing.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-client-incomingmessage-destroy.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread test/parallel/test-http-client-incomingmessage-destroy.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

ronag and others added 2 commits November 30, 2022 11:44
@ronag @aduh95
Apply suggestions from code review
305ade0
Co-authored-by: Antoine du Hamel <[email protected]>
@ronag
fixup
fd82016
@ronag ronag added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 30, 2022
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 30, 2022
@nodejs-github-bot

nodejs-github-bot commented Nov 30, 2022

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/48246/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Dec 1, 2022
CI Reliability 2022-12-01 nodejs/reliability#445
Open
10 tasks
Flarna
Flarna approved these changes Dec 1, 2022
View reviewed changes
@nodejs-github-bot

nodejs-github-bot commented Dec 1, 2022

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/48260/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Dec 2, 2022
CI Reliability 2022-12-02 nodejs/reliability#446
Open
10 tasks
JungMinu
JungMinu approved these changes Dec 2, 2022
View reviewed changes
aduh95
aduh95 approved these changes Dec 2, 2022
View reviewed changes
@aduh95
aduh95 merged commit d385106 into nodejs:main Dec 2, 2022
@aduh95

aduh95 commented Dec 2, 2022

Copy link
Copy Markdown
Contributor

Landed in d385106

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Dec 3, 2022
CI Reliability 2022-12-03 nodejs/reliability#447
Open
CI Reliability 2022-12-04 nodejs/reliability#448
Open
CI Reliability 2022-12-05 nodejs/reliability#449
Open
CI Reliability 2022-12-07 nodejs/reliability#450
Open
CI Reliability 2022-12-08 nodejs/reliability#451
Open
targos pushed a commit that referenced this pull request Dec 12, 2022
@ronag @targos
http: make OutgoingMessage more streamlike
d64e773
Implement missing getters error & closed. Add support for
proper "writable" check through `isWritable` helper.

We cannot fix the `OutgoingMessage.writable` property as that
would break the ecosystem.

PR-URL: #45672
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@targos targos mentioned this pull request Dec 12, 2022
v19.3.0 release proposal #45831
Merged
@danielleadams danielleadams mentioned this pull request Dec 30, 2022
v18.13.0 release proposal #46025
Merged
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
@ronag @danielleadams
http: make OutgoingMessage more streamlike
5a1745e
Implement missing getters error & closed. Add support for
proper "writable" check through `isWritable` helper.

We cannot fix the `OutgoingMessage.writable` property as that
would break the ecosystem.

PR-URL: #45672
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
@ronag @danielleadams
http: make OutgoingMessage more streamlike
cbd710b
Implement missing getters error & closed. Add support for
proper "writable" check through `isWritable` helper.

We cannot fix the `OutgoingMessage.writable` property as that
would break the ecosystem.

PR-URL: #45672
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
danielleadams pushed a commit that referenced this pull request Jan 5, 2023
@ronag @danielleadams
http: make OutgoingMessage more streamlike
9025d6c
Implement missing getters error & closed. Add support for
proper "writable" check through `isWritable` helper.

We cannot fix the `OutgoingMessage.writable` property as that
would break the ecosystem.

PR-URL: #45672
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Gerhard Stöbich <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@jridgewell jridgewell mentioned this pull request Jul 6, 2023
Reimplement stream cancellation vercel/next.js#52281
Merged
ijjk pushed a commit to vercel/next.js that referenced this pull request Jul 26, 2023
@jridgewell
Reimplement stream cancellation (#52281)
31d2b72
### What?

This reimplements our stream cancellation code for a few more cases:
1. Adds support in all stream-returning APIs
2. Fixes cancellation detection in node 16
3. Implements out-of-band detection, so can cancel in the middle of a
read

It also (finally) adds tests for all the cases I'm aware of.

### Why?

To allow disconnecting from an AI service when a client disconnects. $$$

### How?

1. Reuses a single pipe function in all paths to push data from the
dev's `ReadableStream` into our `ServerResponse`
2. Uses `ServerResponse` to detect disconnect, instead of the
`IncomingMessage` (request)
    - The `close` event fire once all incoming body data is read
- The request `abort` event will not fire after the incoming body data
has been fully read
3. Using `on('close')` on the writable destination allows us to detect
close
- Checking for `res.destroyed` in the body of the loop meant we had to
wait for the `await stream.read()` to complete before we could possibly
cancel the stream

- - -

#52157 (and #51594) had an issue with Node 16, because I was using
`res.closed` to detect when the server response was closed by the client
disconnecting. But, `closed` wasn't
[added](nodejs/node#45672) until
[v18.13.0](https://nodejs.org/en/blog/release/v18.13.0#:~:text=%5Bcbd710bbf4%5D%20%2D%20http%3A%20make%20OutgoingMessage%20more%20streamlike%20(Robert%20Nagy)%20%2345672).
This fixes it by using `res.destroyed`.

Reverts #52277
Relands #52157
Fixes #52809

---------
Strift pushed a commit to Strift/next.js that referenced this pull request Jul 27, 2023
@jridgewell Strift
Reimplement stream cancellation (vercel#52281)
0117968
### What?

This reimplements our stream cancellation code for a few more cases:
1. Adds support in all stream-returning APIs
2. Fixes cancellation detection in node 16
3. Implements out-of-band detection, so can cancel in the middle of a
read

It also (finally) adds tests for all the cases I'm aware of.

### Why?

To allow disconnecting from an AI service when a client disconnects. $$$

### How?

1. Reuses a single pipe function in all paths to push data from the
dev's `ReadableStream` into our `ServerResponse`
2. Uses `ServerResponse` to detect disconnect, instead of the
`IncomingMessage` (request)
    - The `close` event fire once all incoming body data is read
- The request `abort` event will not fire after the incoming body data
has been fully read
3. Using `on('close')` on the writable destination allows us to detect
close
- Checking for `res.destroyed` in the body of the loop meant we had to
wait for the `await stream.read()` to complete before we could possibly
cancel the stream

- - -

vercel#52157 (and vercel#51594) had an issue with Node 16, because I was using
`res.closed` to detect when the server response was closed by the client
disconnecting. But, `closed` wasn't
[added](nodejs/node#45672) until
[v18.13.0](https://nodejs.org/en/blog/release/v18.13.0#:~:text=%5Bcbd710bbf4%5D%20%2D%20http%3A%20make%20OutgoingMessage%20more%20streamlike%20(Robert%20Nagy)%20%2345672).
This fixes it by using `res.destroyed`.

Reverts vercel#52277
Relands vercel#52157
Fixes vercel#52809

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

Reviewers

@mcollina mcollina mcollina approved these changes
@JungMinu JungMinu JungMinu approved these changes
@aduh95 aduh95 aduh95 approved these changes
@Flarna Flarna Flarna approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. http Issues and PRs related to the http subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@ronag @nodejs-github-bot @ShogunPanda @aduh95 @mcollina @JungMinu @Flarna
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.