python-sdks icon indicating copy to clipboard operation
python-sdks copied to clipboard

Fix: Start ByteStreamWriter chunk index at 0 #430

Open 5Hyeons opened this issue 8 months ago • 1 comments

This PR fixes a bug in ByteStreamWriter where the first data chunk was incorrectly sent with chunk_index = 1 instead of the expected 0.

Problem: As described in Issue #430 , the _next_chunk_index was incremented before being used in the write method, causing incompatibility with clients (like the Unity SDK's ByteStreamReader) that expect stream chunk indices to start at 0. This differs from the behavior of TextStreamWriter, which correctly starts at index 0.

Changes: The ByteStreamWriter.write method has been modified to: Use the current value of _next_chunk_index (which starts at 0 in BaseStreamWriter) for the chunk_index. Increment _next_chunk_index after the chunk message has been sent via _send_chunk. This aligns the behavior with TextStreamWriter and ensures correct 0-based indexing for byte streams, resolving client-side errors related to chunk index expectation.

5Hyeons avatar May 02 '25 09:05 5Hyeons

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar May 02 '25 09:05 CLAassistant