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

stdio: make stdout and stderr emit 'close' on destroy #26691

Closed
wants to merge 1 commit into from

Conversation

@mcollina
Copy link
Member

commented Mar 15, 2019

The problem in #26550 was caused by net.Socket having set emitClose: false  because it was emitted its own event in _destroy(), and stdio.js was overriding _destroy without emitting 'close'.

Fix: #26550

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@mcollina mcollina requested review from addaleax and gireeshpunathil Mar 15, 2019

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 15, 2019

if (!this._writableState.emitClose) {
process.nextTick(() => {
this.emit('close');
});

This comment has been minimized.

Copy link
@BridgeAR

BridgeAR Mar 15, 2019

Member

How come the nextTick is required in this case?

This comment has been minimized.

Copy link
@mcollina

mcollina Mar 15, 2019

Author Member

The previous cb() could emitting an error via nextTick. Close should be emitted afterwards.

This comment has been minimized.

Copy link
@mcollina

mcollina Mar 17, 2019

Author Member

Are you ok/can this PR land, or would you like to see some different resolution for this?

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 16, 2019

// SyncWriteStream does not use the stream
// destroy mechanism for some legacy reason.
// TODO(mcollina): remove when
// https://github.com/nodejs/node/pull/26690 lands.

This comment has been minimized.

Copy link
@addaleax

addaleax Mar 16, 2019

Member

What exactly are you intending to remove? The dummyDestroy() function? It’s intentional that stdio streams, SyncWriteStream or not, cannot “really” be closed (so that file descriptors 0, 1, 2 don’t accidentally get closed).

This comment has been minimized.

Copy link
@mcollina

mcollina Mar 16, 2019

Author Member

The if check underneath. See the linked PR. Basically we can have a callback or not for this function.

This comment has been minimized.

Copy link
@bnoordhuis

bnoordhuis Mar 20, 2019

Member

#26690 was merged so this needs to go now?

This comment has been minimized.

Copy link
@mcollina

mcollina Mar 20, 2019

Author Member

We can! However that was a semver-major commit and this is not. I would prefer to issue a follow-up PR that will not be backported. This can (and should) be backported.

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 17, 2019

@nodejs/build can you take a look at https://ci.nodejs.org/job/node-test-commit-linux/26139/nodes=ubuntu1604-64/console? there seems a problem with that machine, if failed a couple of times.

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 17, 2019

@rvagg

This comment has been minimized.

Copy link
Member

commented Mar 17, 2019

I've updated, cleaned and rebooted that ubuntu machine, will see if that helps

@Trott

This comment has been minimized.

Copy link
Member

commented Mar 17, 2019

there seems a problem with that machine, if failed a couple of times.

A root-owned directory was left around after some troubleshooting (generating a core file for another issue), and git operations were failing because they couldn't clean up the directory. I removed the directory several hours ago (when I noticed the problem because it failed in node-daily-master) and it should be back to working.

Resume Build CI: https://ci.nodejs.org/job/node-test-pull-request/21615/

@Trott Trott added the author ready label Mar 18, 2019

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 20, 2019

I will look to land this next Monday if there are no further objections. I'd also open a new PR to remove that if check at the same time.

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 25, 2019

Landed in bdea725

@mcollina mcollina closed this Mar 25, 2019

mcollina added a commit that referenced this pull request Mar 25, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: #26550

PR-URL: #26691
Fixes: https://github.com/false
Fixes: #26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>

@mcollina mcollina deleted the mcollina:fix-26550 branch Mar 25, 2019

mcollina added a commit to mcollina/node that referenced this pull request Mar 25, 2019
process: remove protection for SyncWriteStream destroy in stdio
nodejs#26691 introduced an if to protect
against SyncWriteStream not using the default .destroy() mechanism.
This change removes that as SyncWriteStream now use standard .destroy().

See: nodejs#26691
@lpinca

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

Commit landed with messed up metadata, I guess it's too late to fix it.

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Mar 25, 2019

Ouch, I didn't notice. I relied too blindly on git node land.

@joyeecheung

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

We should probably add some stricter checks in https://github.com/nodejs/core-validate-commit for these cases

targos added a commit to targos/node that referenced this pull request Mar 27, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: nodejs#26550

PR-URL: nodejs#26691
Fixes: https://github.com/false
Fixes: nodejs#26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos added a commit to targos/node that referenced this pull request Mar 27, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: nodejs#26550

PR-URL: nodejs#26691
Fixes: https://github.com/false
Fixes: nodejs#26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos added a commit to targos/node that referenced this pull request Mar 27, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: nodejs#26550

PR-URL: nodejs#26691
Fixes: https://github.com/false
Fixes: nodejs#26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos added a commit that referenced this pull request Mar 27, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: #26550

PR-URL: #26691
Fixes: https://github.com/false
Fixes: #26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@targos targos referenced this pull request Mar 27, 2019
mcollina added a commit that referenced this pull request Mar 28, 2019
process: remove protection for SyncWriteStream destroy in stdio
#26691 introduced an if to protect
against SyncWriteStream not using the default .destroy() mechanism.
This change removes that as SyncWriteStream now use standard .destroy().

See: #26691

PR-URL: #26902
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@richardlau richardlau referenced this pull request Mar 31, 2019
@richardlau

This comment has been minimized.

Copy link
Member

commented Mar 31, 2019

We should probably add some stricter checks in https://github.com/nodejs/core-validate-commit for these cases

nodejs/core-validate-commit#54

BethGriggs added a commit that referenced this pull request Apr 5, 2019
process: remove protection for SyncWriteStream destroy in stdio
#26691 introduced an if to protect
against SyncWriteStream not using the default .destroy() mechanism.
This change removes that as SyncWriteStream now use standard .destroy().

See: #26691

PR-URL: #26902
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@BethGriggs

This comment has been minimized.

Copy link
Member

commented Jul 9, 2019

@mcollina should this still land on v10.x?

@mcollina

This comment has been minimized.

Copy link
Member Author

commented Jul 9, 2019

Yes please

BethGriggs added a commit that referenced this pull request Jul 9, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: #26550

PR-URL: #26691
Fixes: https://github.com/false
Fixes: #26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
BethGriggs added a commit that referenced this pull request Jul 17, 2019
process: make stdout and stderr emit 'close' on destroy
Fix: #26550

PR-URL: #26691
Fixes: https://github.com/false
Fixes: #26550
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@BethGriggs BethGriggs referenced this pull request Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.