mirror of https://github.com/lukechilds/node.git
Browse Source
If `.setEncoding` was called on input stream - all emitted `data` will be `String`s instances, not `Buffer`s. This is unacceptable for `StreamWrap`, and should not lead to the crash. Fix: https://github.com/nodejs/node/issues/3970 PR-URL: https://github.com/nodejs/node/pull/4031 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>process-exit-stdio-flushing
Fedor Indutny
9 years ago
2 changed files with 36 additions and 3 deletions
@ -0,0 +1,23 @@ |
|||
'use strict'; |
|||
const common = require('../common'); |
|||
const assert = require('assert'); |
|||
|
|||
const StreamWrap = require('_stream_wrap'); |
|||
const Duplex = require('stream').Duplex; |
|||
|
|||
const stream = new Duplex({ |
|||
read: function() { |
|||
}, |
|||
write: function() { |
|||
} |
|||
}); |
|||
|
|||
stream.setEncoding('ascii'); |
|||
|
|||
const wrap = new StreamWrap(stream); |
|||
|
|||
wrap.on('error', common.mustCall(function(err) { |
|||
assert(/StringDecoder/.test(err.message)); |
|||
})); |
|||
|
|||
stream.push('ohai'); |
Loading…
Reference in new issue