Skip to content

Conversation

justinmk
Copy link
Member

@justinmk justinmk commented Oct 11, 2024

This is a demo for a potential issue noticed in #419 / #414 (comment)

Problem

proc.on('close') does not always trigger on nvim.quit(). Based on the failures from the test changes in this PR, it appears that sometimes the child (nvim) does not close the stderr pipe:

    expect(received).toStrictEqual(expected) // deep equality

    - Expected  - 1
    + Received  + 1

      Object {
        "errors": 0,
    -   "stderrClosed": true,
    +   "stderrClosed": false,
        "stdoutClosed": true,
      }

      172 |     // TODO: 'close' event sometimes does not emit. #414
      173 |     proc.on('exit', () => {
    > 174 |       expect(r).toStrictEqual({
          |                 ^
      175 |         stdoutClosed: true,
      176 |         stderrClosed: true,
      177 |         errors: 0,

      at ChildProcess.toStrictEqual (src/attach/attach.test.ts:174:17)

Solution

This seems like a potential bug or at least something to document in Nvim itself. I thought it might be related to this: https://github.com/neovim/neovim/blob/c4762b309714897615607f135aab9d7bcc763c4f/src/nvim/channel.c#L168-L171

      // Don't close on exit, in case late error messages
      if (!exiting) {
        fclose(stderr);
      }

but, forcing fclose(stderr) does not pass the tests in this PR. Nor does adding fclose(stderr) anywhere else AFAICT.

@justinmk justinmk marked this pull request as draft October 11, 2024 15:04
@justinmk justinmk closed this Oct 17, 2024
@justinmk justinmk deleted the test-proc-close branch October 17, 2024 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant