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

bug/feat: implement WebSocket::bufferedAmount / backpressure #988

Open
threepointone opened this issue Aug 8, 2023 · 3 comments
Open

bug/feat: implement WebSocket::bufferedAmount / backpressure #988

threepointone opened this issue Aug 8, 2023 · 3 comments
Labels
Durable Objects https://developers.cloudflare.com/durable-objects/ feature request Request for Workers team to add a feature

Comments

@threepointone
Copy link

Hiya! I just noticed that bufferedAmount isn't implemented on WebSocket (https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/bufferedAmount). It's not a perfect solution for backpressure, but it would be better than not having it at all.

In the future, what is your opinion on proposals like WebSocketStream? https://github.com/ricea/websocketstream-explainer/

@kentonv
Copy link
Member

kentonv commented Aug 10, 2023

I think bufferedAmount could trivially be implemented to add up the size of all messages in outgoingMessages. cc @MellowYarker who did most of the recent WebSocket improvements.

WebSocketStream seems like a good idea, and given that it reuses the Streams API it might not be too difficult to implement? @jasnell might have an opinion. But I guess it's not a standard yet.

@joshthoward joshthoward added the Durable Objects https://developers.cloudflare.com/durable-objects/ label Oct 25, 2023
@jasnell
Copy link
Member

jasnell commented Oct 26, 2023

Just spotted this, sorry for the late response. WebSocketStream is nicer and is definitely on my radar but I think it needs to bake a bit longer before we can safely consider it.

@rikka0w0
Copy link

Just spotted this, sorry for the late response. WebSocketStream is nicer and is definitely on my radar but I think it needs to bake a bit longer before we can safely consider it.

Also, I would suggest that, we should not only allow the use of new WebSocketStream() as a WebSocket client to connect to a remote server, but also allow the incoming request to be upgraded to a "WebSocketStream-pair". If we can somehow create a WebSocketStream out of a "WebSocket", that will be even better.

@jasnell jasnell added the feature request Request for Workers team to add a feature label Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Durable Objects https://developers.cloudflare.com/durable-objects/ feature request Request for Workers team to add a feature
Projects
None yet
Development

No branches or pull requests

5 participants