Skip to content

Commit f321921

Browse files
bnoordhuisMylesBorins
authored andcommitted
tty: fix 'resize' event regression
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]>
1 parent 7ac760b commit f321921

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

lib/internal/bootstrap_node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
const _process = NativeModule.require('internal/process');
3535
_process.setupConfig(NativeModule._source);
36+
_process.setupSignalHandlers();
3637
NativeModule.require('internal/process/warning').setup();
3738
NativeModule.require('internal/process/next_tick').setup();
3839
NativeModule.require('internal/process/stdio').setup();
@@ -55,7 +56,6 @@
5556
_process.setup_cpuUsage();
5657
_process.setupMemoryUsage();
5758
_process.setupKillAndExit();
58-
_process.setupSignalHandlers();
5959
if (global.__coverage__)
6060
NativeModule.require('internal/process/write-coverage').setup();
6161

test/pseudo-tty/pseudo-tty.status

+5
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ prefix pseudo-tty
33
[$system==aix]
44
# being investigated under https://github.com/nodejs/node/issues/9728
55
test-tty-wrap : FAIL, PASS
6+
7+
[$system==solaris]
8+
# https://github.com/nodejs/node/pull/16225 - `ioctl(fd, TIOCGWINSZ)` seems
9+
# to fail with EINVAL on SmartOS when `fd` is a pty from python's pty module.
10+
test-tty-stdout-resize : FAIL, PASS
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
const { mustCall } = require('../common');
3+
const { notStrictEqual } = require('assert');
4+
5+
// tty.WriteStream#_refreshSize() only emits the 'resize' event when the
6+
// window dimensions change. We cannot influence that from the script
7+
// but we can set the old values to something exceedingly unlikely.
8+
process.stdout.columns = 9001;
9+
process.stdout.on('resize', mustCall());
10+
process.kill(process.pid, 'SIGWINCH');
11+
setImmediate(mustCall(() => notStrictEqual(process.stdout.columns, 9001)));

test/pseudo-tty/test-tty-stdout-resize.out

Whitespace-only changes.

0 commit comments

Comments
 (0)