Skip to content

resize event not firing #16194

Closed
Closed

Description

@Flet
  • Version: v8.5.0 through v8.7.0
  • Platform: Darwin
  • Subsystem:

In versions v8.5.0 and higher, the resize event does not seem to fire on terminal window resize.

Test code:

process.stdout.on('resize', function () {
  console.log('resized')
})

setInterval(function () {
}, 0)

I was able to have success when trying v8.4.0, but v8.5.0 does not work.

Possibly related recent closed issue:
#13197

Activity

  1. refack commented on Oct 13, 2017

    @refack
    Contributor

    /cc @nodejs/platform-macos

    @Flet #13197 would have been my first guess too, but it was closed by a documentation change - ff07eaa
    Later the underlying event mechanism was improved in libuv/libuv@6ad1e81 but that change was for Windows only, and your report states Darwin as the platform.

  2. added
    macosIssues and PRs related to the macOS platform.
    ttyIssues and PRs related to the tty subsystem.
    on Oct 13, 2017
  3. bnoordhuis commented on Oct 14, 2017

    @bnoordhuis
    Member

    I'm not sure what broke exactly but it starts working again when you add a no-op process.on('SIGWINCH', () => {}) listener. Manual bisecting indicates it's not the libuv upgrade.

    lib/internal/process/stdio.js installs a SIGWINCH handler but it doesn't fire until another one is added because the 'newListener' handler for signals hasn't been installed yet.

    My initial guess was that some of the inspector changes broke it because the problem goes away with this patch but I haven't pinpointed the cause yet:

    diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js
    index e7676c0867..b9ac545dd1 100644
    --- a/lib/internal/bootstrap_node.js
    +++ b/lib/internal/bootstrap_node.js
    @@ -36,6 +36,7 @@
         const browserGlobals = !process._noBrowserGlobals;
         if (browserGlobals) {
           setupGlobalTimeouts();
    +      _process.setupSignalHandlers();
           setupGlobalConsole();
         }
    
    @@ -57,7 +58,6 @@
         _process.setup_cpuUsage();
         _process.setupMemoryUsage();
         _process.setupKillAndExit();
    -    _process.setupSignalHandlers();
         if (global.__coverage__)
           NativeModule.require('internal/process/write-coverage').setup();
    
  4. maclover7 commented on Oct 14, 2017

    @maclover7
    Contributor

    Did a bisect, and it seems like f34e0f9 is what introduced the new behavior.

  5. refack commented on Oct 14, 2017

    @refack
    Contributor

    @maclover7 , @Flet can you devise a regression test for this? (something like: start a child node process in a terminal, then try to script a resize of that terminal)

    Another good test to have is a unit test of the event on the node side (one that mocks the libuv behaviour)

  6. bnoordhuis commented on Oct 14, 2017

    @bnoordhuis
    Member

    Did a bisect, and it seems like f34e0f9 is what introduced the new behavior.

    That commit was one of my suspects but its code does not exist anymore in v8.6.0, it was removed in 8ce0e9a (which is a somewhat suspect commit as well.)

  7. Fishrock123 commented on Oct 15, 2017

    @Fishrock123
    Contributor

    This sounds reasonable to me, we should set up the signal handlers before loading the console / process.{stdio}.

  8. bnoordhuis commented on Oct 15, 2017

    @bnoordhuis
    Member
  9. added a commit that references this issue on Nov 15, 2017
  10. added a commit that references this issue on Dec 11, 2017
  11. added a commit that references this issue on Dec 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.macosIssues and PRs related to the macOS platform.regressionIssues related to regressions.ttyIssues and PRs related to the tty subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions