don't crash if the PTY suddenly produces strings (#2004, fixes #1955)

This commit is contained in:
Eugene Pankov 2020-01-15 16:07:13 +01:00
parent 1c8288bfe1
commit e9999ee883

View file

@ -38,6 +38,9 @@ module.exports = function patchPTYModule (mod) {
}
terminal.on('data', data => {
if (typeof data === 'string') {
data = Buffer.from(data)
}
buffer = Buffer.concat([buffer, data])
if (Date.now() - lastFlush > maxWindow) {
// Taking too much time buffering, flush to keep things interactive