fix: increase websocket messsage size to 8MB#257
Conversation
WalkthroughThis PR makes two focused changes to WebSocket handling. The maximum message size limit is increased from 64KB to 8MB to accommodate larger payloads. The request logging in 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/websocket.go`:
- Around line 202-204: The truncation currently slices paramsLog by bytes
(paramsLog[:256]) and uses len(req.Params) which can split UTF-8 runes; change
to a rune-safe truncation: convert paramsLog to runes (e.g., []rune(paramsLog)),
if rune length > 256 build a new string from the first 256 runes and append a
suffix that reports the total rune count (len([]rune(req.Params))) so both the
256-character contract and the accurate total are preserved; update the block
that references paramsLog and req.Params accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8f84d7d0-fe8f-404b-91b2-50ba71de60fa
📒 Files selected for processing (1)
server/websocket.go
| if len(paramsLog) > 256 { | ||
| paramsLog = paramsLog[:256] + fmt.Sprintf("…(%d bytes total)", len(req.Params)) | ||
| } |
There was a problem hiding this comment.
Use rune-safe truncation to preserve the 256-character contract.
Line 202/Line 203 currently truncate by bytes (len + [:256]), not characters. This can cut UTF-8 mid-rune and produce invalid output while undercutting the stated 256-character behavior.
Proposed fix
+import "unicode/utf8"
...
- paramsLog := string(req.Params)
- if len(paramsLog) > 256 {
- paramsLog = paramsLog[:256] + fmt.Sprintf("…(%d bytes total)", len(req.Params))
- }
+ paramsLog := string(req.Params)
+ if utf8.RuneCountInString(paramsLog) > 256 {
+ r := []rune(paramsLog)
+ paramsLog = string(r[:256]) + fmt.Sprintf("…(%d bytes total)", len(req.Params))
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if len(paramsLog) > 256 { | |
| paramsLog = paramsLog[:256] + fmt.Sprintf("…(%d bytes total)", len(req.Params)) | |
| } | |
| paramsLog := string(req.Params) | |
| if utf8.RuneCountInString(paramsLog) > 256 { | |
| r := []rune(paramsLog) | |
| paramsLog = string(r[:256]) + fmt.Sprintf("…(%d bytes total)", len(req.Params)) | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@server/websocket.go` around lines 202 - 204, The truncation currently slices
paramsLog by bytes (paramsLog[:256]) and uses len(req.Params) which can split
UTF-8 runes; change to a rune-safe truncation: convert paramsLog to runes (e.g.,
[]rune(paramsLog)), if rune length > 256 build a new string from the first 256
runes and append a suffix that reports the total rune count
(len([]rune(req.Params))) so both the 256-character contract and the accurate
total are preserved; update the block that references paramsLog and req.Params
accordingly.
No description provided.