You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using ws with createWebSocketStream it is not currently clear how to force the writable side of the duplex to use text frames rather than binary. Since the send method is not accessible by design of the stream api, and the duplex option defaults prevent setting the objectMode I was unsure how to proceed.
I noticed that there was an in-progress PR that referenced a very similar issue, notably with the readObjectMode and so I commented there however the maintainers have stated that they thought it should be its own report and rightly so. Meanwhile they did offer a working suggestion, namely setting the decodeStrings option to false. While this does work, I must admit that I had never seen this option for streams before and given its name it seemed to me that it would have done something completely different.
I would propose that either (a) the options object be more flexible so that objectMode could not be set (which overrides the read and write object modes) and writeObjectMode be set to true (this option would conform to my understanding of the paradigm of writing a blob/buffer or string to the websocket to choose its frame type) or else (b) show the decodeStrings in the documentation for createWebSocketStream along with encoding so that others like me will not have to go through this process in the future.
Reproducible in:
version: 7.5.3
Node.js version(s): all
OS version(s): all
The text was updated successfully, but these errors were encountered:
Description
When using ws with
createWebSocketStream
it is not currently clear how to force the writable side of the duplex to use text frames rather than binary. Since thesend
method is not accessible by design of the stream api, and the duplex option defaults prevent setting the objectMode I was unsure how to proceed.I noticed that there was an in-progress PR that referenced a very similar issue, notably with the readObjectMode and so I commented there however the maintainers have stated that they thought it should be its own report and rightly so. Meanwhile they did offer a working suggestion, namely setting the
decodeStrings
option tofalse
. While this does work, I must admit that I had never seen this option for streams before and given its name it seemed to me that it would have done something completely different.I would propose that either (a) the options object be more flexible so that objectMode could not be set (which overrides the
read
andwrite
object modes) andwriteObjectMode
be set to true (this option would conform to my understanding of the paradigm of writing a blob/buffer or string to the websocket to choose its frame type) or else (b) show thedecodeStrings
in the documentation forcreateWebSocketStream
along withencoding
so that others like me will not have to go through this process in the future.Reproducible in:
The text was updated successfully, but these errors were encountered: