1// Flags: --expose-internals 2'use strict'; 3const common = require('../common'); 4 5const StreamWrap = require('internal/js_stream_socket'); 6const Duplex = require('stream').Duplex; 7 8{ 9 const stream = new Duplex({ 10 read() {}, 11 write() {} 12 }); 13 14 stream.setEncoding('ascii'); 15 16 const wrap = new StreamWrap(stream); 17 18 wrap.on('error', common.expectsError({ 19 name: 'Error', 20 code: 'ERR_STREAM_WRAP', 21 message: 'Stream has StringDecoder set or is in objectMode' 22 })); 23 24 stream.push('ohai'); 25} 26 27{ 28 const stream = new Duplex({ 29 read() {}, 30 write() {}, 31 objectMode: true 32 }); 33 34 const wrap = new StreamWrap(stream); 35 36 wrap.on('error', common.expectsError({ 37 name: 'Error', 38 code: 'ERR_STREAM_WRAP', 39 message: 'Stream has StringDecoder set or is in objectMode' 40 })); 41 42 stream.push(new Error('foo')); 43} 44