Skip to content

fix: increase WebSocket max message size to 100MB #1677

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sanity
Copy link
Collaborator

@sanity sanity commented Jun 19, 2025

Summary

  • Increased WebSocket max message size from default (~64KB) to 100MB
  • Fixes issue where PUT requests with large WASM contracts were silently dropped
  • Resolves River invitation bug where room creation was failing

Problem

The default WebSocket message size limit was too small for WASM contracts which can be several hundred KB (River's room contract is 360KB). This caused PUT requests to be silently dropped at the WebSocket protocol level before reaching Freenet's handler.

Solution

Added max_message_size(100 * 1024 * 1024) configuration to the WebSocket upgrade handler.

Testing

  • River PUT operations now work correctly
  • Large contract deployments no longer fail silently
  • Backwards compatible with existing clients

Related Issues

🤖 Generated with Claude Code

The default WebSocket message size limit (~64KB) was too small for
WASM contracts which can be several hundred KB. This caused PUT
requests to be silently dropped at the protocol level, preventing
contract deployment.

Increased max_message_size to 100MB to handle large contracts.

Fixes River invitation bug where PUT operations were failing silently.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
ws.on_upgrade(on_upgrade)
// Increase max message size to 100MB to handle contract uploads
// Default is ~64KB which is too small for WASM contracts
ws.max_message_size(100 * 1024 * 1024)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider this to be a temporal fix, we need to look into different ways of sending messages this large (maybe a regular multipart http request) cause this a bit of an antipattern for ws. I know is over local host but still, we can do better here .

I think eventually we want to stream that right into disk to not hold into such large things in memory for very long, but that requries a bigger architetural change.

Ok(None)
.await;

match send_result {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the worst part that we were silently swallowing this. In the future we should have a regression test for this forcing some sort of error (it can be done at this component level by mocking the rest of the interface, e.g. dropping the other end of the channel).

good catch

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

Successfully merging this pull request may close these issues.

WebSocket GET operations hang when contract not found instead of returning error
2 participants