You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
repl: error thrown while writing function statement in '.editor' mode #9189
When using the REPL's .editor mode, the following error occurs when hitting the 'ENTER' key after a return statement. Tested in both CMD and Git Bash
C:\Users\joe>node -v
v6.9.0
C:\Users\joe>node
> var a = 1
undefined
> .editor
// Entering editor mode (^D to finish, ^C to cancel)
function thing (x) {
return x
readline.js:982
throw err;
^
Error: write EPIPE
at exports._errnoException (util.js:1026:11)
at ReadStream.Socket._writeGeneric (net.js:710:26)
at ReadStream.Socket._write (net.js:729:8)
at doWrite (_stream_writable.js:333:12)
at writeOrBuffer (_stream_writable.js:319:5)
at ReadStream.Writable.write (_stream_writable.js:246:11)
at ReadStream.Socket.write (net.js:656:40)
at REPLServer.<anonymous> (repl.js:479:26)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:188:7)
@addaleax@Fishrock123 Thinking of protecting input stream from writing with inputStream.isTTY && (inputStream.writable || process.platform !== 'win32') predicate. Any suggestion?
@addaleax can we undo the characters written to output stream? In the case of input stream, current line data is still in buffer and user can use backspace to erase white spaces added for alignment
My understanding is, output stream is read only in ttys perspective.
Whose buffer? In the context of the REPL, the TTY is generally in raw mode, so buffering is not really an issue here, and the current line is only stored by our readline.Interface instance.
So, yeah, you’re right, we shouldn’t directly write to the output stream, but call the readline write(). Something like this seems like a correct patch to me:
Activity
cjihrig commentedon Oct 19, 2016
cc: @princejwesley
princejwesley commentedon Oct 19, 2016
Works fine in macOS. I'll try this in windows 10.
princejwesley commentedon Oct 19, 2016
Works fine in
v6.5.0(irrelevant). Writing white spaces to input stream throws this error inv6.9.0.Update: Pipe is closed when write to input stream (#8241). Disable auto alignment feature in windows will fix this issue.
princejwesley commentedon Oct 20, 2016
@addaleax @Fishrock123 Thinking of protecting input stream from writing with
inputStream.isTTY && (inputStream.writable || process.platform !== 'win32')predicate. Any suggestion?addaleax commentedon Oct 20, 2016
Hm, why does the REPL try to write to the input stream here in the first place? Is there any reason not to use the output stream for that?
princejwesley commentedon Oct 20, 2016
@addaleax User can use
backspaceto remove/adjust the alignment.addaleax commentedon Oct 20, 2016
@princejwesley I’m not sure if I’m unaware of something Windows-specific here, but generally, that should work fine when writing to the output stream?
princejwesley commentedon Oct 20, 2016
@addaleax can we undo the characters written to output stream? In the case of input stream, current line data is still in buffer and user can use backspace to erase white spaces added for alignment
My understanding is, output stream is read only in
ttys perspective.addaleax commentedon Oct 20, 2016
Whose buffer? In the context of the REPL, the TTY is generally in raw mode, so buffering is not really an issue here, and the current line is only stored by our
readline.Interfaceinstance.So, yeah, you’re right, we shouldn’t directly write to the output stream, but call the readline
write(). Something like this seems like a correct patch to me:That last piece should probably be added anyway, too, to match the check in
readline.js.What do you think?
princejwesley commentedon Oct 20, 2016
@addaleax Yea, its perfect 👍
addaleax commentedon Oct 20, 2016
Okay, I’ll PR with that then :)
repl: don’t write to input stream in editor mode
repl: don’t write to input stream in editor mode
repl: don’t write to input stream in editor mode