1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

fix write after FIN error when using repl via socket

if repl.outputStream is a socket, it is closed when 'exit' event
occurred, so write throws an exception
This commit is contained in:
Sangmin Yoon 2015-04-22 15:11:56 +09:00
parent 140a73dca7
commit ce10a463f3
2 changed files with 4 additions and 2 deletions

View file

@ -185,7 +185,9 @@
runInContext(opts.prelude, repl.context, 'prelude');
}
repl.on('exit', function() {
return repl.outputStream.write('\n');
if (!repl.rli.closed) {
return repl.outputStream.write('\n');
}
});
addMultilineHandler(repl);
if (opts.historyFile) {

View file

@ -152,7 +152,7 @@ module.exports =
opts = merge replDefaults, opts
repl = nodeREPL.start opts
runInContext opts.prelude, repl.context, 'prelude' if opts.prelude
repl.on 'exit', -> repl.outputStream.write '\n'
repl.on 'exit', -> repl.outputStream.write '\n' if not repl.rli.closed
addMultilineHandler repl
addHistory repl, opts.historyFile, opts.historyMaxInputSize if opts.historyFile
# Adapt help inherited from the node REPL