fix: pdcp data loss, pipeline conn leak, Close() race, FilterCustom error swallowing - #2549
fix: pdcp data loss, pipeline conn leak, Close() race, FilterCustom error swallowing#2549tal7aouy wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
WalkthroughThe change fixes callback error propagation, pipeline connection cleanup, and PDCP writer behavior. It also prevents oversized result loss and makes writer channel closure safe for repeated calls. ChangesFilter callback handling
Pipeline connection cleanup
PDCP writer correctness
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
Fixes four bugs found during a code audit of the codebase.
Bugs Fixed
1. PDCP Writer: Data Loss When Chunk Exceeds
MaxChunkSizeFile:
internal/pdcp/writer.goWhen a result line would push the buffer over
MaxChunkSize(4 MB), the buffer was flushed, but the current line was never written to the newly emptied buffer. This silently dropped every result that triggered a flush.Before
After
2. Pipeline: Connection Leak in
SupportPipelineFile:
common/httpx/pipeline.goThe dialed TCP/TLS connection was never closed on either the success or error path, leaking one file descriptor per call.
A
defer conn.Close()was added immediately after a successful connection.3. PDCP Writer: Race Condition in
Close()File:
internal/pdcp/writer.goThe
Load()→close()→Store()sequence aroundclose(u.data)was not atomic. Concurrent calls toClose()could both pass the check, causing the secondclose(u.data)to panic with:Replaced the sequence with an atomic
CompareAndSwap.Before
After
4.
FilterCustom: Errors from Callbacks Silently SwallowedFile:
common/httpx/filter.goIf a callback returned either
(true, error)or(false, error), the error was silently discarded and iteration continued. As a result, the function could incorrectly return(false, nil)even though a callback had returned an error.Errors are now propagated immediately.
Before
After
Test Plan
go test ./common/httpx/ -run TestFilterCustom -vok=trueok=falsego vet ./common/httpx/ ./internal/pdcp/go build ./common/httpx/ ./internal/pdcp/go test ./common/httpx/ -short -count=1Summary by CodeRabbit
Bug Fixes
Tests