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

Non-ConPTY PTYs fail on node 14 #457

Closed
Eugeny opened this issue Feb 6, 2021 · 2 comments · Fixed by #460
Closed

Non-ConPTY PTYs fail on node 14 #457

Eugeny opened this issue Feb 6, 2021 · 2 comments · Fixed by #460

Comments

@Eugeny
Copy link
Contributor

Eugeny commented Feb 6, 2021

Windows 10 / Node 14.15.2 (and latest Electron 12 betas which use the same Node) / node-pty 0.10 and 0.9

Repro:

np = require('node-pty')
pty = np.spawn('cmd.exe', [], { useConpty: false })
pty.write('123')

Result:

Uncaught Error: This socket has been ended by the other party
    at Socket.writeAfterFIN [as write] (net.js:456:14)
    at WindowsTerminal._doWrite (C:\Users\Eugene\Documents\tmp\node_modules\node-pty\lib\windowsTerminal.js:115:30)
    at WindowsTerminal._defer (C:\Users\Eugene\Documents\tmp\node_modules\node-pty\lib\windowsTerminal.js:157:24)
    at WindowsTerminal._write (C:\Users\Eugene\Documents\tmp\node_modules\node-pty\lib\windowsTerminal.js:112:14)
    at WindowsTerminal.Terminal.write (C:\Users\Eugene\Documents\tmp\node_modules\node-pty\lib\terminal.js:82:14) {
  code: 'EPIPE'

The child process is in fact alive and the node-pty object is marked _writable:

> pty
WindowsTerminal {
  _onData: EventEmitter2 { _listeners: [] },
  _onExit: EventEmitter2 { _listeners: [] },
  _internalee: EventEmitter {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    [Symbol(kCapture)]: false
  },
  handleFlowControl: false,
  _flowControlPause: '\x13',
  _flowControlResume: '\x11',
  _cols: 80,
  _rows: 24,
  _isReady: true,
  _deferreds: [],
  _agent: WindowsPtyAgent {
    _useConpty: false,
    _ptyNative: {
      startProcess: [Function: startProcess],
      resize: [Function: resize],
      kill: [Function: kill],
      getExitCode: [Function: getExitCode],
      getProcessList: [Function: getProcessList]
    },
    _pid: 700,
    _innerPid: 17624,
    _innerPidHandle: 624,
    _fd: -1,
    _pty: 2,
    _outSocket: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 9,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: null,
      _server: null,
      [Symbol(async_id_symbol)]: 325,
      [Symbol(kHandle)]: [Pipe],
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0
    },
    _inSocket: Socket {
      connecting: false,
      _hadError: false,
      _parent: null,
      _host: null,
      _readableState: [ReadableState],
      _events: [Object: null prototype],
      _eventsCount: 1,
      _maxListeners: undefined,
      _writableState: [WritableState],
      allowHalfOpen: false,
      _sockname: null,
      _pendingData: null,
      _pendingEncoding: '',
      server: null,
      _server: null,
      write: [Function: writeAfterFIN],
      [Symbol(async_id_symbol)]: 327,
      [Symbol(kHandle)]: null,
      [Symbol(kSetNoDelay)]: false,
      [Symbol(lastWriteQueueSize)]: 0,
      [Symbol(timeout)]: null,
      [Symbol(kBuffer)]: null,
      [Symbol(kBufferCb)]: null,
      [Symbol(kBufferGen)]: null,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesRead)]: 0,
      [Symbol(kBytesWritten)]: 0
    }
  },
  _socket: <ref *1> Socket {
    connecting: false,
    _hadError: false,
    _parent: null,
    _host: null,
    _readableState: ReadableState {
      objectMode: false,
      highWaterMark: 16384,
      buffer: BufferList { head: null, tail: null, length: 0 },
      length: 0,
      pipes: [],
      flowing: true,
      ended: false,
      endEmitted: false,
      reading: true,
      sync: false,
      needReadable: true,
      emittedReadable: false,
      readableListening: false,
      resumeScheduled: false,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: false,
      destroyed: false,
      errored: null,
      closed: false,
      closeEmitted: false,
      defaultEncoding: 'utf8',
      awaitDrainWriters: null,
      multiAwaitDrain: false,
      readingMore: false,
      decoder: [StringDecoder],
      encoding: 'utf8',
      [Symbol(kPaused)]: false
    },
    _events: [Object: null prototype] {
      end: [Array],
      connect: [Function (anonymous)],
      ready_datapipe: [Function (anonymous)],
      data: [Array],
      exit: [Function (anonymous)],
      timeout: [Function (anonymous)],
      drain: [Function (anonymous)],
      error: [Function (anonymous)],
      finalCalled: true,
      needDrain: false,
      ending: true,
      ended: true,
      finished: true,
      destroyed: false,
      decodeStrings: false,
      defaultEncoding: 'utf8',
      length: 0,
      writing: false,
      corked: 0,
      sync: true,
      bufferProcessing: false,
      onwrite: [Function: bound onwrite],
      writecb: null,
      writelen: 0,
      afterWriteTickInfo: null,
      buffered: [],
      bufferedIndex: 0,
      allBuffers: true,
      allNoop: true,
      pendingcb: 0,
      prefinished: true,
      errorEmitted: false,
      emitClose: false,
      autoDestroy: false,
      errored: null,
      closed: false,
      closeEmitted: false,
      writable: true
    },
    allowHalfOpen: false,
    _sockname: null,
    _pendingData: null,
    _pendingEncoding: '',
    server: null,
    _server: null,
    [Symbol(async_id_symbol)]: 325,
    [Symbol(kHandle)]: Pipe { reading: true, [Symbol(owner_symbol)]: [Circular *1] },
    [Symbol(kSetNoDelay)]: false,
    [Symbol(lastWriteQueueSize)]: 0,
    [Symbol(timeout)]: null,
    [Symbol(kBuffer)]: null,
    [Symbol(kBufferCb)]: null,
    [Symbol(kBufferGen)]: null,
    [Symbol(kCapture)]: false,
    [Symbol(kBytesRead)]: 0,
    [Symbol(kBytesWritten)]: 0
  },
  _pid: 17624,
  _fd: -1,
  _pty: 2,
  _file: 'cmd.exe',
  _name: 'xterm-256color',
  _readable: true,
  _writable: true
}
@Eugeny Eugeny changed the title Non-ConPTY PTYs fail on node 14.15.2 Non-ConPTY PTYs fail on node 14 Feb 6, 2021
@Eugeny
Copy link
Contributor Author

Eugeny commented Feb 6, 2021

I've just bisected Node versions on this and it starts with 14.0.0. 13.14.0 is the latest working one.

@Eugeny
Copy link
Contributor Author

Eugeny commented Feb 6, 2021

It does indeed look like all input pipes get closed immediately:

PS C:\Users\Eugene> get-childitem \\.\pipe\ | select name |select-string winpty

@{Name=winpty-control-14940-1-1d6fcad448361b9-b11498c1c53384807187091a42f951f0}
@{Name=winpty-conout-22100-2-1d6fcad448ac9cf-4620a48d1b4d9b4b655560eaaaf0a4a6}
@{Name=winpty-control-14940-2-1d6fcad5fdfbc59-a2c438a08089fec0dd531088dc657647}
@{Name=winpty-conout-3320-2-1d6fcad5fe70f5d-4b3b54777360756b9f8a10e1e26274db}
@{Name=winpty-control-14940-3-1d6fcb5b25f4bec-17308da0cca887ab1cbb3af9a0258d10}
@{Name=winpty-conout-30052-2-1d6fcb5b26eef76-2f7f708075fa0fb3b795108095d6270a}
@{Name=winpty-control-14940-4-1d6fcb5f521d22b-29daf19d70c5764bd4dffceccacb228f}
@{Name=winpty-conout-2728-2-1d6fcb5f52e1c85-104c66586ad7e45f597b091fc56afed6}
@{Name=winpty-control-14940-5-1d6fcb68ed8ce83-cf8217061e0088940abe3dbb38118fb0}
@{Name=winpty-conout-28520-2-1d6fcb68ee26f2c-e4f0cd8fca81ac8f52fe958e920d4218}
@{Name=winpty-control-14940-6-1d6fcb6ac966ecf-fe27855f87c6480a688b813a3c90d452}
@{Name=winpty-conout-24876-2-1d6fcb6aca15a3e-8e33e17c27678159c0ef185c8fc4738d}

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 a pull request may close this issue.

1 participant