Skip to content

Conversation

@xianshijing-lk
Copy link
Contributor

@xianshijing-lk xianshijing-lk commented Jan 19, 2026

This PR will allows client SDKs to generate an async id for the async requests, and start a listener before passing the requests, so that it could fix the race conditions.

Summary by CodeRabbit

  • New Features
    • Enhanced async operation tracking and request correlation support across audio capture, data streams, room operations, RPC calls, and track statistics to improve asynchronous request-response mapping.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 19, 2026

📝 Walkthrough

Walkthrough

This PR extends multiple protobuf request messages across the FFI protocol with an optional request_async_id field to enable request-response correlation. The Rust server implementation is updated to resolve provided async IDs instead of generating new ones. TypeScript bindings are regenerated to reflect the schema changes.

Changes

Cohort / File(s) Summary
Protocol Definitions
livekit-ffi/protocol/audio_frame.proto, livekit-ffi/protocol/data_stream.proto, livekit-ffi/protocol/room.proto, livekit-ffi/protocol/rpc.proto, livekit-ffi/protocol/track.proto
Added optional request_async_id (uint64) field to request messages across all protocols: CaptureAudioFrameRequest, various stream requests (ByteStreamReader/Writer, TextStreamReader/Writer), room operation requests (Connect, Disconnect, PublishTrack, PublishData, etc.), PerformRpcRequest, and GetStatsRequest. Field numbers assigned appropriately per message.
Rust Server Core
livekit-ffi/src/server/mod.rs
Added new public method resolve_async_id() that returns provided request_async_id if present, otherwise generates new ID via next_id().
Rust Server Handlers
livekit-ffi/src/server/audio_source.rs, livekit-ffi/src/server/data_stream.rs, livekit-ffi/src/server/participant.rs, livekit-ffi/src/server/requests.rs, livekit-ffi/src/server/room.rs
Updated async ID resolution across multiple handlers: replaced server.next_id() with server.resolve_async_id(request.request_async_id) to use client-provided IDs. Affects audio capture, stream operations, RPC invocation, participant actions, and room operations.
Generated TypeScript Bindings
livekit-ffi-node-bindings/src/proto/audio_frame_pb.ts, livekit-ffi-node-bindings/src/proto/data_stream_pb.ts, livekit-ffi-node-bindings/src/proto/room_pb.ts, livekit-ffi-node-bindings/src/proto/rpc_pb.ts, livekit-ffi-node-bindings/src/proto/track_pb.ts
Regenerated TypeScript message classes with new optional requestAsyncId?: bigint field and corresponding FieldList entries for all request messages mirroring protobuf changes.
CI/CD
.github/workflows/gen-node-proto.yml
Removed recursive submodules checkout step from GitHub Actions workflow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


🐰 Async IDs now flow like carrots in a stream,
From client requests to server's gleaming dream.
No more random IDs, just correlation bliss,
Requests and responses now know each other's kiss! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change: adding a request_async_id field to async request messages across multiple proto files and corresponding implementation files.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1668e49 and e7ffdf1.

📒 Files selected for processing (6)
  • .github/workflows/gen-node-proto.yml
  • livekit-ffi-node-bindings/src/proto/audio_frame_pb.ts
  • livekit-ffi-node-bindings/src/proto/data_stream_pb.ts
  • livekit-ffi-node-bindings/src/proto/room_pb.ts
  • livekit-ffi-node-bindings/src/proto/rpc_pb.ts
  • livekit-ffi-node-bindings/src/proto/track_pb.ts
💤 Files with no reviewable changes (1)
  • .github/workflows/gen-node-proto.yml
🔇 Additional comments (31)
livekit-ffi-node-bindings/src/proto/track_pb.ts (1)

341-356: LGTM — request_async_id is wired in cleanly.

livekit-ffi-node-bindings/src/proto/rpc_pb.ts (1)

103-122: LGTM — optional request_async_id added for RPC correlation.

livekit-ffi-node-bindings/src/proto/audio_frame_pb.ts (1)

506-539: LGTM — request_async_id added to CaptureAudioFrameRequest.

livekit-ffi-node-bindings/src/proto/data_stream_pb.ts (12)

151-166: LGTM — async id addition is consistent for read-all requests.


534-549: LGTM — request_async_id added for byte read-all requests.


672-706: LGTM — write-to-file request now supports async correlation.


973-990: LGTM — file-send requests now accept request_async_id.


1125-1142: LGTM — byte-send requests now accept request_async_id.


1277-1294: LGTM — text-send requests now accept request_async_id.


1468-1484: LGTM — stream open requests now accept request_async_id.


1612-1628: LGTM — stream writer write requests now accept request_async_id.


1743-1759: LGTM — stream writer close requests now accept request_async_id.


1920-1936: LGTM — text stream open requests now accept request_async_id.


2064-2080: LGTM — text stream writer write requests now accept request_async_id.


2195-2211: LGTM — text stream writer close requests now accept request_async_id.

livekit-ffi-node-bindings/src/proto/room_pb.ts (16)

175-192: LGTM — ConnectRequest includes requestAsyncId.
Field declaration and FieldList entry are aligned.


410-425: LGTM — DisconnectRequest async ID hook added.
Optional field and metadata wiring look consistent.


539-556: LGTM — PublishTrackRequest requestAsyncId added.
Schema field and TS property are in sync.


689-706: LGTM — UnpublishTrackRequest requestAsyncId added.
Field list update matches the new property.


847-868: LGTM — PublishDataRequest requestAsyncId added.
Definition and FieldList entry align.


993-1011: LGTM — PublishTranscriptionRequest requestAsyncId added.
Optional field is properly registered.


1136-1154: LGTM — PublishSipDtmfRequest requestAsyncId added.
No issues spotted.


1269-1285: LGTM — SetLocalMetadataRequest requestAsyncId added.
Looks consistent with the proto field list.


1408-1426: LGTM — SendChatMessageRequest requestAsyncId added.
Field registration matches the new property.


1474-1493: LGTM — EditChatMessageRequest requestAsyncId added.
Everything lines up.


1621-1637: LGTM — SetLocalAttributesRequest requestAsyncId added.
No concerns.


1795-1811: LGTM — SetLocalNameRequest requestAsyncId added.
Field metadata matches the new property.


1995-2010: LGTM — GetSessionStatsRequest requestAsyncId added.
Consistent with schema wiring.


5150-5168: LGTM — SendStreamHeaderRequest requestAsyncId added.
Looks correct.


5211-5229: LGTM — SendStreamChunkRequest requestAsyncId added.
No issues.


5272-5290: LGTM — SendStreamTrailerRequest requestAsyncId added.
Field list is updated appropriately.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

Copy link
Contributor

@cloudwebrtc cloudwebrtc left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@ladvoc ladvoc left a comment

Choose a reason for hiding this comment

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

LGTM ✅, just a few unnecessary clones that should be removed prior to merging.

@xianshijing-lk xianshijing-lk force-pushed the sxian/CLT-2463/add_request_async_id_to_ffi_async_reqeusts branch from e871581 to 1668e49 Compare January 22, 2026 20:06
@xianshijing-lk xianshijing-lk merged commit ff6041e into main Jan 23, 2026
6 checks passed
@xianshijing-lk xianshijing-lk deleted the sxian/CLT-2463/add_request_async_id_to_ffi_async_reqeusts branch January 23, 2026 00:07
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
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.

4 participants