Skip to content

fix: more accurate streaming statuses#3593

Open
astandrik wants to merge 3 commits intomainfrom
astandrik.3592
Open

fix: more accurate streaming statuses#3593
astandrik wants to merge 3 commits intomainfrom
astandrik.3592

Conversation

@astandrik
Copy link
Collaborator

@astandrik astandrik commented Mar 8, 2026

Closes #3592


Note

Medium Risk
Changes how streaming multipart parts are decoded in StreamingAPI, which can affect query streaming and status updates if the Content-Length handling is wrong. Risk is mitigated by size guards, fallback to part.text(), and new unit/e2e tests covering split/oversized/async chunk delivery.

Overview
Improves streaming query chunk decoding by replacing part.text() with a new readPartText helper that reads exactly Content-Length bytes from the part’s ReadableStream, correctly handling bodies delivered across multiple chunks (with a 64MB cap and fallback to part.text() when length is missing/invalid).

Adds coverage for partial network delivery: unit tests for readPartText (multi-chunk, byte-by-byte, oversized chunk clamping, async delays) and a Playwright test plus mock enhancements to split the initial SessionCreated multipart part, ensuring streaming status reaches Running before completing.

Written by Cursor Bugbot for commit 1406eef. This will update automatically on new commits. Configure here.

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
416 413 0 1 2
Test Changes Summary ✨1

✨ New Tests (1)

  1. Streaming query reaches "Running" when SessionCreated arrives in split chunks (tenant/queryEditor/queryStatus.test.ts)

Bundle Size: ✅

Current: 62.93 MB | Main: 62.93 MB
Diff: +2.28 KB (0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

@astandrik
Copy link
Collaborator Author

@greptile review
@cursor review

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses incorrect/unstable streaming query status updates by ensuring multipart parts are fully read even when delivered across multiple ReadableStream chunks (e.g., partial network delivery), and adds regression tests for this scenario.

Changes:

  • Add readPartText() helper to robustly read multipart part bodies using Content-Length and stream accumulation.
  • Update StreamingAPI multipart parsing to use readPartText() instead of part.text().
  • Extend Playwright streaming mock and tests to simulate and validate split-chunk delivery of the SessionCreated part.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/utils/mockStreamingFetch.ts Adds option to split the session multipart part across two chunks to simulate partial network delivery.
tests/suites/tenant/queryEditor/queryStatus.test.ts Adds E2E coverage ensuring status reaches “Running” even when SessionCreated arrives split.
src/services/api/streamingPartReader.ts Introduces readPartText() to accumulate multipart body bytes reliably.
src/services/api/streaming.ts Switches multipart part reading from part.text() to readPartText().
src/services/api/test/readPartText.test.ts Adds unit tests covering single/multi-chunk and delayed chunk delivery for readPartText().

@astandrik
Copy link
Collaborator Author

@greptile review
@cursor review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

@astandrik astandrik marked this pull request as ready for review March 8, 2026 10:23
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.

fix: more accurate streaming statuses

2 participants