Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify use of text frames with streams #1915

Closed
jberger opened this issue Jul 13, 2021 · 2 comments
Closed

Clarify use of text frames with streams #1915

jberger opened this issue Jul 13, 2021 · 2 comments

Comments

@jberger
Copy link

jberger commented Jul 13, 2021

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 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
@lpinca
Copy link
Member

lpinca commented Jul 14, 2021

I'm closing this as answered. Discussion can continue if needed.

@lpinca lpinca closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants