Skip to content

Commit 6fa51d6

Browse files
bnoordhuisgibfahn
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 13e853f commit 6fa51d6

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
@@ -29,6 +29,7 @@
2929

3030
const _process = NativeModule.require('internal/process');
3131
_process.setupConfig(NativeModule._source);
32+
_process.setupSignalHandlers();
3233
NativeModule.require('internal/process/warning').setup();
3334
NativeModule.require('internal/process/next_tick').setup();
3435
NativeModule.require('internal/process/stdio').setup();
@@ -51,7 +52,6 @@
5152
_process.setup_cpuUsage();
5253
_process.setupMemoryUsage();
5354
_process.setupKillAndExit();
54-
_process.setupSignalHandlers();
5555
if (global.__coverage__)
5656
NativeModule.require('internal/process/write-coverage').setup();
5757

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)