Skip to content

fix(ocx-child): bound WebSocket event retention - #8801

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:fix/child-ws-frame-event-budget
Nov 17, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
luvs01:fix/child-ws-frame-event-budget

Conversation

@luvs01

@luvs01 luvs01 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Handle each completed WebSocket frame event before parsing the next event from the same socket read. Completed fragmented messages no longer accumulate full-capacity payload buffers in an intermediate event vector.
  • Convert payload reservation failure into a connection-level 1009 fault. Preserve the existing message and fragment limits, masking, UTF-8 validation, close behavior, and wire ordering.
  • Keep link-ws-test-gate absent from ordinary builds. Add bounded parser coverage, a real feature-enabled relay regression, and the owning runtime contract.

Verification

Recorded local validation:

  • cargo test --locked --manifest-path native/ocx-child/Cargo.toml --lib: 57 passed, 0 failed.
  • cargo test --locked --manifest-path native/ocx-child/Cargo.toml --features link-ws-test-gate --lib --test link_websocket: 56 library tests and 5 real-binary integration tests passed.
  • Standalone frame-reader regression run: 14 passed, 0 failed.
  • A bounded comparison using a 64 KiB message limit failed under the former batched-consumption model and passed with single-event consumption. Retained completed-message capacity fell from 44,695,552 bytes to a peak of 65,536 bytes in that synthetic case. No allocator-exhaustion or operating-system OOM test was run.
  • bun run typecheck (2,533 files), bun run structure:check, bun run privacy:scan, file-size ratchet, Rust formatting, and staged diff checks passed.

Upstream validation for bf259f16c346accb29f91121e3562b509860b2db passed: Cross-platform CI and PR gates. The Ubuntu remote-helper job ran ocx-child formatting, clippy and default-feature Cargo tests successfully. The feature-enabled link_websocket real-binary result is the recorded local result above; it was not run by that CI job. Skipped Bun/full/native-platform lanes are not claimed as executed.

An additional read-only review of this exact commit covered event-buffer ownership, frame/protocol boundaries, reservation failure, teardown and feature gating, and found no blocking issue. It did not rerun tests or perform an OOM or live installation test. Installed/live application validation and explicit maintainer security review before merge remain separate.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

The security checkbox records implementation review; explicit maintainer security review remains required before merge.

Summary by CodeRabbit

  • Bug Fixes

    • WebSocket connections now continue processing coalesced frames in order, including after fragmented messages, and close promptly when a frame cannot be processed.
    • Improved handling of payload allocation failures to prevent excessive resource use.
  • Tests

    • Added coverage for coalesced messages, close frames, and continued connection availability.
  • Documentation

    • Clarified WebSocket frame storage and payload handling.

Consume completed frame events before parsing later messages in the same read.
Handle payload reservation failure as a connection fault and preserve the
existing test-only feature gate, framing limits, and close behavior.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The frame reader now returns one event at a time and uses fallible payload allocation. The relay processes each event before parsing more input and handles parse faults immediately. Tests cover coalesced messages, parsing boundaries, and allocation failure.

Changes: WebSocket Event Processing

Layer / File(s) Summary
Incremental frame parsing
native/ocx-child/src/link_ws_frame.rs, native/ocx-child/tests/link_websocket.rs, structure/remote-link.md
FrameReader::next_event returns one event and leaves later input unconsumed. Fragment and message payload buffers use fallible allocation, with reservation failures mapped to TooLarge. Tests cover coalesced frames, input boundaries, and allocation failure.
Relay event processing
native/ocx-child/src/link_ws.rs, native/ocx-child/tests/link_websocket.rs, structure/remote-link.md
pump handles each event before parsing more input and terminates immediately on a parse fault using the existing direction-specific close actions. Relay tests check coalesced fragmented messages and subsequent use of the same and a second connection. Documentation describes the bounded storage and sequential event handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · up to bf259

This change bounds memory retained when one WebSocket read contains many coalesced messages, and it closes the connection with 1009 if payload allocation fails. No concrete merge-blocking risk was found in the supplied evidence.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(ocx-child): bound WebSocket event retention" matches the main change. The raw summary and objectives show that FrameReader now consumes one completed event at a time, releasing complete…
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.
Full details: Title check

Explanation

The title "fix(ocx-child): bound WebSocket event retention" matches the main change. The raw summary and objectives show that FrameReader now consumes one completed event at a time, releasing completed payloads before the next event is parsed. Payload reservation failure now returns a 1009 fault, which bounds retained memory. The title names the component and the main goal, and it follows a conventional commit style.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 595de1e and bf259f1.

Files selected for processing: 4

  • native/ocx-child/src/link_ws.rs
  • native/ocx-child/src/link_ws_frame.rs
  • native/ocx-child/tests/link_websocket.rs
  • structure/remote-link.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev under MAINTAINERS.md (not an approving review), 2026-11-17 triage round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants