nodejs / readable-stream

Node-core streams for userland
https://nodejs.org/api/stream.html
Other
1.03k stars 227 forks source link

modify write method for Uint8Array output #417

Closed tomcat008 closed 4 years ago

tomcat008 commented 5 years ago

When I use MQTT.js in wechat and publish ArrayBuffer message,the subclient cannot recv the message. I debugged the program and found in _stream_writable.js "write" method the ArrayBuffer payload encoding is converted to “utf-8”,cannot convert to Buffer。 I've made changes and passed the test in the project.

rexagod commented 4 years ago

ping @tomcat008

vweevers commented 4 years ago

The current code works as intended. In objectMode, the input is taken as-is (and we cannot change that as @rexagod wrote). If not in objectMode, then UInt8Arrays are converted to Buffers. That does not include ArrayBuffers though; if you want that to be supported (I'm not sure we should) please open an issue in node. Thanks!