mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
de2fd63612
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>
24 lines
446 B
JavaScript
24 lines
446 B
JavaScript
'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');
|