mirror of
https://github.com/nodejs/node.git
synced 2024-11-29 23:16:30 +01:00
1b54371c50
Using objectMode with stream_wrap has not worked properly before and would end in an error. Therefore prohibit the usage of objectMode alltogether. This also improves the handling performance due to the cheaper chunk check and by using explicit statements as they produce better code from the compiler. PR-URL: https://github.com/nodejs/node/pull/13863 Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
43 lines
789 B
JavaScript
43 lines
789 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
const StreamWrap = require('_stream_wrap');
|
|
const Duplex = require('stream').Duplex;
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {},
|
|
write() {}
|
|
});
|
|
|
|
stream.setEncoding('ascii');
|
|
|
|
const wrap = new StreamWrap(stream);
|
|
|
|
wrap.on('error', common.expectsError({
|
|
type: Error,
|
|
code: 'ERR_STREAM_WRAP',
|
|
message: 'Stream has StringDecoder set or is in objectMode'
|
|
}));
|
|
|
|
stream.push('ohai');
|
|
}
|
|
|
|
{
|
|
const stream = new Duplex({
|
|
read() {},
|
|
write() {},
|
|
objectMode: true
|
|
});
|
|
|
|
const wrap = new StreamWrap(stream);
|
|
|
|
wrap.on('error', common.expectsError({
|
|
type: Error,
|
|
code: 'ERR_STREAM_WRAP',
|
|
message: 'Stream has StringDecoder set or is in objectMode'
|
|
}));
|
|
|
|
stream.push(new Error('foo'));
|
|
}
|