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

tty: fix 'resize' event regression #16225

Merged
merged 1 commit into from
Nov 15, 2017
Merged

Conversation

bnoordhuis
Copy link
Member

@bnoordhuis bnoordhuis commented Oct 15, 2017

It's not wholly clear what commit introduced the regression but between
v8.4.0 and v8.5.0 the 'resize' event stopped getting emitted when the
tty was resized.

The SIGWINCH event listener apparently was being installed before the
support code for process.on('SIGWINCH', ...) was. Fix that by moving
said support code to real early in the bootstrap process.

Fixes: #16194
CI: https://ci.nodejs.org/job/node-test-pull-request/10732/

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Oct 15, 2017
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

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

LGTM if the CI passes.

process.stdout.columns = 9001;
process.stdout.on('resize', mustCall());
process.kill(process.pid, 'SIGWINCH');
setImmediate(mustCall(() => notStrictEqual(process.stdout.columns, 9001)));
Copy link
Member

Choose a reason for hiding this comment

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

Nit: it doesn't harm but I think mustCall() is useless here.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's there in case a bug makes the immediate not run. Since this PR touches early-boot code it seems like a good extra sanity check

@seishun
Copy link
Contributor

seishun commented Oct 18, 2017

This fixes #16141. Can someone explain why?

@jasnell
Copy link
Member

jasnell commented Oct 18, 2017

This failed on smartos: https://ci.nodejs.org/job/node-test-commit-smartos/12229/

@bnoordhuis
Copy link
Member Author

I think that's a pty + smartos issue, not anything specific to this PR. I've added an exception in the status file.

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

@bnoordhuis
Copy link
Member Author

...but cc @nodejs/platform-smartos in case you want to investigate.

@bzoz
Copy link
Contributor

bzoz commented Oct 18, 2017

@seishun: this does not seem to fix #16141 on my Win10 box.

@seishun
Copy link
Contributor

seishun commented Oct 18, 2017

@bzoz just in case, you modified index.js to run the built binary instead of global node, right?

@bzoz
Copy link
Contributor

bzoz commented Oct 19, 2017

@seishun yeah, I've changed it to process.argv0. From #16289 I guess you are running Win7, #16141 seem to happen on newest Win10 only

@seishun
Copy link
Contributor

seishun commented Oct 19, 2017

Strange. I can reproduce #16141 on both Windows 10 build 15063 and Windows 7. But this PR only fixes it on Windows 7.

@Fishrock123
Copy link
Contributor

Still LGTM

@bnoordhuis
Copy link
Member Author

It's not wholly clear what commit introduced the regression but between
v8.4.0 and v8.5.0 the 'resize' event stopped getting emitted when the
tty was resized.

The SIGWINCH event listener apparently was being installed before the
support code for `process.on('SIGWINCH', ...)` was.  Fix that by moving
said support code to real early in the bootstrap process.

This commit also seems to fix a Windows-only "write EINVAL" error for
reasons even less well-understood...

Fixes: nodejs#16141
Fixes: nodejs#16194
PR-URL: nodejs#16225
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
@bnoordhuis
Copy link
Member Author

Landed in 9c1b18a.

@bnoordhuis bnoordhuis merged commit 9c1b18a into nodejs:master Nov 15, 2017
MylesBorins pushed a commit that referenced this pull request Dec 11, 2017
It's not wholly clear what commit introduced the regression but between
v8.4.0 and v8.5.0 the 'resize' event stopped getting emitted when the
tty was resized.

The SIGWINCH event listener apparently was being installed before the
support code for `process.on('SIGWINCH', ...)` was.  Fix that by moving
said support code to real early in the bootstrap process.

This commit also seems to fix a Windows-only "write EINVAL" error for
reasons even less well-understood...

Fixes: #16141
Fixes: #16194
PR-URL: #16225
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 12, 2017
@gibfahn
Copy link
Member

gibfahn commented Dec 19, 2017

The test here passes on v8.x-staging and v6.x-staging (without the other changes). Should this be backported or should we just backport the test?

@bnoordhuis
Copy link
Member Author

There's been some shuffling in bootstrap_node.js that probably fixed the regression by accident. Back-porting the test is a good idea, IMO.

gibfahn pushed a commit that referenced this pull request Dec 20, 2017
It's not wholly clear what commit introduced the regression but between
v8.4.0 and v8.5.0 the 'resize' event stopped getting emitted when the
tty was resized.

The SIGWINCH event listener apparently was being installed before the
support code for `process.on('SIGWINCH', ...)` was.  Fix that by moving
said support code to real early in the bootstrap process.

This commit also seems to fix a Windows-only "write EINVAL" error for
reasons even less well-understood...

Fixes: #16141
Fixes: #16194
PR-URL: #16225
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
@gibfahn gibfahn mentioned this pull request Dec 20, 2017
@sam-github
Copy link
Contributor

What does

+[$system==solaris]
+# https://github.com/nodejs/node/pull/16225 - `ioctl(fd, TIOCGWINSZ)` seems
+# to fail with EINVAL on SmartOS when `fd` is a pty from python's pty module.
+test-tty-stdout-resize     : FAIL, PASS

this mean, specifically, FAIL,PASS in the status? Its not clear if this is still an issue, in which case there should be an open issue about it, or if its not an issue, can we delete the special notations from the test/pseudo-tty/pseudo-tty.status file?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resize event not firing