Skip to content

increase buffer size for stream to lines to accomodate oversize packets#3112

Merged
sawka merged 1 commit intomainfrom
sawka/fix-silent-packet-drops
Mar 24, 2026
Merged

increase buffer size for stream to lines to accomodate oversize packets#3112
sawka merged 1 commit intomainfrom
sawka/fix-silent-packet-drops

Conversation

@sawka
Copy link
Member

@sawka sawka commented Mar 24, 2026

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

Walkthrough

The maxLineLength constant in pkg/util/utilfn/streamtolines.go was increased from 128 KB to 64 MB. This threshold controls when the streamToLines_processBuf function enters "long line" mode and determines the maximum size of buffered lines before discarding incomplete lines or emitting complete lines. The change allows the function to buffer significantly larger lines before triggering long-line handling behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 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; the pull request relies solely on the title to convey intent. Consider adding a description explaining the business impact (silent packet drops) and technical rationale for the specific buffer size increase.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: increasing buffer size in stream-to-lines functionality to handle larger packets.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sawka/fix-silent-packet-drops

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 24, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • pkg/util/utilfn/streamtolines.go

The change increases maxLineLength from 128KB to 64MB to accommodate legacy file transfer packets that can be up to 32MB when base64 encoded. This is a straightforward and reasonable fix.


Reviewed by minimax-m2.5-20260211 · 164,401 tokens

Copy link
Contributor

@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 the current code and only fix it if needed.

Inline comments:
In `@pkg/util/utilfn/streamtolines.go`:
- Around line 23-25: The global const maxLineLength is too large for all callers
and should be scoped to RPC usage; change the shared constant into a smaller
safe default (e.g., defaultMaxLineLength) and add an RPC-specific limit (e.g.,
rpcMaxLineLength) or an explicit constructor/parameter for StreamToLines and
LineWriter so callers can opt into the 64MB cap only for RPC streams; update
StreamToLines and LineWriter to accept a configurable maxLineLength parameter
(or provide NewStreamToLinesWithLimit / NewLineWriterWithLimit) and use
defaultMaxLineLength when not provided, reserving the 64MB value only for
RPC-specific construction paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3e7f142e-f314-4675-8c5f-20e1117e0ee3

📥 Commits

Reviewing files that changed from the base of the PR and between 6a287e4 and 424cb65.

📒 Files selected for processing (1)
  • pkg/util/utilfn/streamtolines.go

Comment on lines +23 to +25
// needs to be large enough to read the largest RPC packet
// there are some legacy file transfer packets that can send up to 32m (base64 encoded)
const maxLineLength = 64 * 1024 * 1024
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Scope the 64MB cap to RPC-specific usage instead of changing the global default.

This constant is shared by both StreamToLines and LineWriter, so Line 25 now allows ~64MB buffering per in-flight line for all callers. That can materially increase memory pressure under concurrent streams. Prefer a configurable limit (or an RPC-specific constructor/path with 64MB) while keeping a safer general default.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/util/utilfn/streamtolines.go` around lines 23 - 25, The global const
maxLineLength is too large for all callers and should be scoped to RPC usage;
change the shared constant into a smaller safe default (e.g.,
defaultMaxLineLength) and add an RPC-specific limit (e.g., rpcMaxLineLength) or
an explicit constructor/parameter for StreamToLines and LineWriter so callers
can opt into the 64MB cap only for RPC streams; update StreamToLines and
LineWriter to accept a configurable maxLineLength parameter (or provide
NewStreamToLinesWithLimit / NewLineWriterWithLimit) and use defaultMaxLineLength
when not provided, reserving the 64MB value only for RPC-specific construction
paths.

@sawka sawka merged commit 176657d into main Mar 24, 2026
7 checks passed
@sawka sawka deleted the sawka/fix-silent-packet-drops branch March 24, 2026 19:18
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