Repository navigation
Conversation
Wrap the FFI's write-to-file so a received byte stream can be written straight to disk by the SDK core, which also rejects sender-chosen file names that are not plain file names (path separators, "..", absolute paths, empty). Write-to-file and incremental reading both consume the FFI reader handle, so byte readers now start reading lazily: the first readNext() / readAll() starts incremental reading, writeToFile() hands the stream to the core instead, and a reader closed or destroyed unconsumed drops its handle. Room tracks byte readers weakly so an ignored reader releases its stream rather than being kept alive by the room. Ports the Rust write_to_file tests end to end, plus the one-consumer rule, the event-thread guard and ignored readers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RoomOptions::data_stream.max_payload_byte_length caps how many (decompressed) bytes each incoming data stream may carry. A stream that exceeds it ends with a DataStreamError on its reader. When unset, the SDK core's default (5 GB) applies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ports the Rust incoming-manager max_payload_byte_length tests through RoomOptions::data_stream: a stream that grows past the limit, one whose declared total exceeds it (rejected before any data), one exactly at the limit, and inline (compressed and uncompressed) and compressed multi-packet streams that breach it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 30, 2026
Author
|
CI for this branch (manually dispatched, since |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 4 of 5 of the data streams v2 stack. Merge in order; each part is mergeable on its own.
sendText/sendBytes/sendFileByteStreamReader::writeToFileand a receive size limit 👈 this PRstreamText/streamBytesThis stack replaces #321, #322 and #325 (same code, reordered so each step stands on its own).
Two receive-side additions.
ByteStreamReader::writeToFile()Writes a received byte stream straight to disk through the SDK core.
.., absolute paths, or empty names.Write-to-file and incremental reading both consume the FFI reader handle, so byte readers now start lazily:
readNext()/readAll()starts reading, orwriteToFile()hands the stream to the core instead;Roomholds byte readers byweak_ptr, so a reader the app ignores releases its stream instead of being kept alive by the room.Text readers are unchanged.
Receive size limit
RoomOptions::data_stream.max_payload_byte_lengthcaps the decompressed size of each incoming stream. A stream that goes over it ends with aDataStreamError. When unset, the core's default of 5 GB applies.Tests
test_data_stream_conformance_write_to_file.cppwriteToFile()from the stream handler, and ignored readers not blocking later streamstest_data_stream_conformance_receive_api.cpptest_data_streams.cpp,test_data_stream.cpp(unit)RoomOptionsconversionRust tests covered here
Follow-ups from the #325 review
writeToFilereplaces an existing file and follows a symlink at the destination. Both come from Rust'sFile::create. Do not overwrite or follow a symlink in write_to_file rust-sdks#1605 switches tocreate_new(approved, not yet released). Once it ships, bumping the submodule fixes it here; the doc line "An existing file is overwritten" then needs updating.RoomOptionslayout. Addingdata_streamchanges the struct's layout, so an app must be recompiled (not just relinked) against the new headers. That matches earlierRoomOptionsadditions (v1.2.0, v1.7.0). A layout-stable alternative would be a separate setter orconnect()overload.Verification (local, macOS arm64,
livekit-server --dev)DataTrackE2ETestschema tests (DefineAndGetSchema,DefineAndGetCustomSchemaEncoding,DefineDuplicateSchemaFails). They fail onmainon this machine too, and the 1 skip is the token-server test.🤖 Generated with Claude Code