Skip to content

fix: increase websocket messsage size to 8MB#257

Open
gmegidish wants to merge 1 commit into
mainfrom
fix-increase-websocket-max-message-size
Open

fix: increase websocket messsage size to 8MB#257
gmegidish wants to merge 1 commit into
mainfrom
fix-increase-websocket-max-message-size

Conversation

@gmegidish
Copy link
Copy Markdown
Member

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 7, 2026

Walkthrough

This 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 handleWSMessage is updated to truncate parameter values to 256 characters and display the total byte length via a suffix when truncation occurs, preventing large parameters from dominating log output.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the rationale for increasing the WebSocket message size limit and any related context or impact.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: increasing the WebSocket message size limit from 64KB to 8MB.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-increase-websocket-max-message-size

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9246f88 and 87806e3.

📒 Files selected for processing (1)
  • server/websocket.go

Comment thread server/websocket.go
Comment on lines +202 to +204
if len(paramsLog) > 256 {
paramsLog = paramsLog[:256] + fmt.Sprintf("…(%d bytes total)", len(req.Params))
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

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.

Suggested change
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.

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.

1 participant