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: fix missing close event on aborted response by not-implemented · Pull Request #1373 · nodejs/node

Conversation

@not-implemented

@not-implemented not-implemented commented Apr 8, 2015

Copy link
Copy Markdown
Contributor

When sending a response after client aborted the connection in the same tick when the socket is already destroyed but the socket-close event is still not delivered, you did not get either a response-finish or a response-close event.

This fix of the race-condition needs an additional flag "_finishOrCloseEmitted" in OutgoingMessage.

I did not find any easier solution - I tried to fix this either with an additional "close" or an additional "finish" with some timing-tricks without an additional flag. I had no chance without breaking anything else.

Not all of the new checks of "_finishOrCloseEmitted" are currently really needed - they are just for completeness.

Sorry, something went wrong.

Uh oh!

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

All reactions
@not-implemented
http: fix missing close event on aborted response
79f7f34
When sending a response after client aborted the connection in the same
tick when the socket is already destroyed but the socket-close event is
still not delivered, you did not get either a response-finish or a
response-close event.

This fix of the race-condition needs an additional flag
"_finishOrCloseEmitted" in OutgoingMessage.
@not-implemented not-implemented mentioned this pull request Apr 8, 2015
No finish/close event on aborted http-response - race condition #1309
Closed
@Fishrock123 Fishrock123 added the http Issues and PRs related to the http subsystem. label Apr 8, 2015
@Fishrock123

Fishrock123 commented Apr 8, 2015

Copy link
Copy Markdown
Contributor

cc @indutny?

All reactions

Sorry, something went wrong.

Uh oh!

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

brendanashworth
brendanashworth reviewed Apr 12, 2015
View reviewed changes
Comment thread test/parallel/test-http-response-close-event-race.js

@brendanashworth brendanashworth Apr 12, 2015

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.

usually, passing tests should be silent; could you remove the expected console.logs?

Sorry, something went wrong.

Uh oh!

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

All reactions

@not-implemented not-implemented Apr 12, 2015

Copy link
Copy Markdown
Contributor Author

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.

Of course I could remove them - I kept with the other tests which also contain console.logs (output is hidden anyway in normal test run).
I thought, especially race conditions are much more understandable with some debugging output - also for future refactoring/debugging.

Sorry, something went wrong.

Uh oh!

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

All reactions

@indutny indutny Apr 12, 2015

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.

Please keep them for now :) I've a bit delayed this, but going to review it next week!

Sorry, something went wrong.

Uh oh!

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

All reactions
indutny pushed a commit to indutny/io.js that referenced this pull request Apr 13, 2015
@not-implemented @indutny
test: add test for missing close/finish event
b6b37a5
See next commit for the actual fix.

PR-URL: nodejs#1373
Reviewed-By: Fedor Indutny <[email protected]>
indutny added a commit to indutny/io.js that referenced this pull request Apr 13, 2015
@indutny
http_server: prefinish vs finish
2811b0c
Do not detach the socket from the response until all data is actually
sent to the other side.

See: nodejs#1373
@indutny indutny mentioned this pull request Apr 13, 2015
Use finish instead of prefinish in _http_server.js #1411
Closed
@indutny

indutny commented Apr 13, 2015

Copy link
Copy Markdown
Member

@not-implemented PTAL at #1411 . I have integrated your test, but decided to choose a bit different way to fix the issue.

All reactions

Sorry, something went wrong.

Uh oh!

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

@indutny

indutny commented Apr 13, 2015

Copy link
Copy Markdown
Member

Thank you for discovering this!

All reactions

Sorry, something went wrong.

Uh oh!

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

@not-implemented

not-implemented commented Apr 13, 2015

Copy link
Copy Markdown
Contributor Author

Ah very cool ... I didn't have the guts to delay the WHOLE finish-handling - only parts of it ;-)
Thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

@not-implemented not-implemented closed this Apr 13, 2015
@indutny

indutny commented Apr 13, 2015

Copy link
Copy Markdown
Member

Thank you!

All reactions

Sorry, something went wrong.

Uh oh!

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

indutny pushed a commit to indutny/io.js that referenced this pull request Apr 15, 2015
@not-implemented @indutny
test: add test for missing close/finish event
7170741
See next commit for the actual fix.

PR-URL: nodejs#1373
Reviewed-By: Fedor Indutny <[email protected]>
indutny added a commit to indutny/io.js that referenced this pull request Apr 15, 2015
@indutny
http_server: prefinish vs finish
6b03dd8
Do not detach the socket from the response until all data is actually
sent to the other side.

See: nodejs#1373
indutny pushed a commit to indutny/io.js that referenced this pull request Jun 1, 2015
@not-implemented @indutny
test: add test for missing close/finish event
159577c
See next commit for the actual fix.

PR-URL: nodejs#1373
Reviewed-By: Fedor Indutny <[email protected]>
indutny added a commit to indutny/io.js that referenced this pull request Jun 1, 2015
@indutny
http_server: prefinish vs finish
854a071
Do not detach the socket from the response until all data is actually
sent to the other side.

See: nodejs#1373
indutny added a commit that referenced this pull request Jun 5, 2015
@indutny @Fishrock123
http_server: prefinish vs finish
6020d2a
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Jun 17, 2015
@indutny @chrisdickinson
http_server: prefinish vs finish
646d67b
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny pushed a commit that referenced this pull request Jul 4, 2015
@not-implemented @indutny
test: add test for missing close/finish event
9436a86
See next commit for the actual fix.

PR-URL: #1373
Reviewed-By: Fedor Indutny <[email protected]>
indutny pushed a commit that referenced this pull request Jul 4, 2015
@not-implemented @indutny
test: add test for missing close/finish event
7387297
See next commit for the actual fix.

PR-URL: #1373
Reviewed-By: Fedor Indutny <[email protected]>
@Fishrock123 Fishrock123 mentioned this pull request Jul 6, 2015
Release proposal: v2.3.4 #2115
Merged
indutny added a commit that referenced this pull request Jul 22, 2015
@indutny @rvagg
http_server: prefinish vs finish
ce1acd5
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Jul 24, 2015
@indutny @rvagg
http_server: prefinish vs finish
9b1341c
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Jul 30, 2015
@indutny @rvagg
http_server: prefinish vs finish
577acc4
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Aug 1, 2015
@indutny @rvagg
http_server: prefinish vs finish
da5ba35
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Aug 3, 2015
@indutny @rvagg
http_server: prefinish vs finish
d1974e2
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Aug 4, 2015
@indutny @rvagg
http_server: prefinish vs finish
9f3946a
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
indutny added a commit that referenced this pull request Aug 4, 2015
@indutny @rvagg
http_server: prefinish vs finish
11e4249
Do not detach the socket from the response until all data is actually
sent to the other side.

See: #1373
PR-URL: #1411
Reviewed-By: Chris Dickinson <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
@JanCantCode JanCantCode mentioned this pull request Aug 23, 2022
Program does not work until restart after stopped with ctrl + c #44363
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

No one assigned

Labels

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.

4 participants

@not-implemented @Fishrock123 @indutny @brendanashworth
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 01402775 — 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.