Skip to content

Allow sending Bytes via WebSocket#16216

Closed
carlhoerberg wants to merge 1 commit intocrystal-lang:masterfrom
carlhoerberg:websocket-send-bytes
Closed

Allow sending Bytes via WebSocket#16216
carlhoerberg wants to merge 1 commit intocrystal-lang:masterfrom
carlhoerberg:websocket-send-bytes

Conversation

@carlhoerberg
Copy link
Contributor

Crystal 1.18.0 regression

Crystal 1.18.0 regression
@ysbaddaden
Copy link
Collaborator

I believe other methods that take a message are also affected, such as #pong.

It also means we're missing specs for the bytes case.

@straight-shoota straight-shoota added this to the 1.18.1 milestone Oct 15, 2025
@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:networking kind:regression Something that used to correctly work but no longer works labels Oct 15, 2025
@straight-shoota
Copy link
Member

straight-shoota commented Oct 15, 2025

We have a spec that tests sending Bytes, but it calls WebSocket::Protocol#send directly instead of the wrapper WebSocket#send 🤷

@straight-shoota
Copy link
Member

Actually, WebSocket::Protocol#send (and similar methods) accept any type that responds to #to_slice. So even String | Bytes seems too narrow.
I'm not sure if that's really necessary, and I wouldn't mind narrowing that down and require conversion at the call site if necessary. But that would be a different change.
For now it's probably best just to remove the type restrictions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:stdlib:networking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants