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

WebSockets: TCP fragmentation needs to be handled #9052

Open
argosphil opened this issue Feb 22, 2024 · 0 comments
Open

WebSockets: TCP fragmentation needs to be handled #9052

argosphil opened this issue Feb 22, 2024 · 0 comments
Labels
bug Something isn't working web-api Something that relates to a standard Web API

Comments

@argosphil
Copy link
Contributor

What version of Bun is running?

1.0.28+705638470

What platform is your computer?

No response

What steps can reproduce the bug?

This is a follow-up to #9027.

WebSockets are implemented using TCP (or Unix domain sockets). TCP has fragmentation. The WebSockets protocol also has fragmentation. They are distinct and happen at different layers. That confused me.

Our code currently does not handle TCP fragmentation for WebSockets connections. That's not usually a problem because TCP connections tend to send out each WebSockets frame in a new TCP packet. But sometimes it is, so it should be fixed.

This bug can be reproduced by running a WebSockets server which sends out each byte in an individual TCP packet, or simulating one by splitting the data after receiving it.

What is the expected behavior?

The expected behavior is that our WebSockets code handles all possible TCP fragmentation types, including single-byte packets for everything.

What do you see instead?

Using single-byte packets, in the client code, WS pings and pongs currently fail. I haven't tested the server code yet. Fragmentation that happens in the WS payload appears to be handled by the existing code.

Additional information

I'm testing code locally which fixes the client and will open a PR soon.

@argosphil argosphil added the bug Something isn't working label Feb 22, 2024
@Electroid Electroid added the web-api Something that relates to a standard Web API label Feb 23, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 24, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 24, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 24, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 24, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 25, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 26, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 27, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 28, 2024
argosphil added a commit to argosphil/bun that referenced this issue Feb 29, 2024
argosphil added a commit to argosphil/bun that referenced this issue Mar 3, 2024
argosphil added a commit to argosphil/bun that referenced this issue Mar 4, 2024
argosphil added a commit to argosphil/bun that referenced this issue Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web-api Something that relates to a standard Web API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants