Closed
Description
- Version: v5.8.0
- Platform: Darwin 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64
- Subsystem: stream
I've tried node 5.8.0, 5.10.0 and 4.4.2. I always receive string objects in my data handler unless I manually remove the decoder from the socket readableState:
const server = net.createServer( ( c ) => {
// See https://nodejs.org/api/stream.html#stream_readable_setencoding_encoding
c.setEncoding( null );
// Hack that must be added to make this work as expected
delete c._readableState.decoder;
c.on( 'data', ( d ) => {
// Expect 'object' but get 'string' without deleting the decoder manually
console.log( typeof d );
} );
} );