Skip to content

fix(client): report upload chunk parse errors on completion (fixes #7736) - #7759

Merged
FarhanAliRaza merged 2 commits into
reflex-dev:mainfrom
thekarak:fix-upload-chunk-errors
Nov 19, 2026
Merged

FarhanAliRaza merged 2 commits into
reflex-dev:mainfrom
thekarak:fix-upload-chunk-errors

Conversation

@thekarak

@thekarak thekarak commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

closes #7736

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description of Changes

Problem:
During file uploads, streamed responses lack a Content-Length header (Transfer-Encoding: chunked), meaning event.lengthComputable is false and progress === 1 is never evaluated as true. As a result, malformed chunks that failed parsing were silently ignored and never logged. In addition, xhr.onload resolved the upload promise without a final pass over the complete response.

Fix:

  • eventHandler(responseText, complete = false) in packages/reflex-frontend/src/utils/helpers/upload.js replaces the progress-ratio check with a completion flag. xhr.onprogress no longer computes a progress ratio.
  • xhr.onload calls eventHandler(xhr.responseText, true) for a 2xx response, before the error-frame check from fix(upload): answer a failing upload handler with a 500 or an error frame #7808. So an error frame that only the final pass sees still fails the upload.
  • A chunk that does not parse is logged once, when the response is complete. This is also true when the response has a Content-Length header.
  • An empty response is skipped, so it logs nothing.
  • Tests in tests/units/reflex_base/client_upload.mjs: a bad chunk is logged at load, a final chunk is completed after the last progress event, a response has no progress events, a progress ratio of 1 is not completion, an error frame is seen only at load, and an empty response. The existing error-status test covers the non-2xx case.
  • Newsfragment: packages/reflex-base/news/+upload-completion-errors.bugfix.md.

View guided diff

@thekarak
thekarak requested a review from a team as a code owner November 6, 2026 09:42

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Upload responses now get a final parse pass when the request completes, so malformed chunks are logged even without a Content-Length header.

  • File uploads check the full response when the request finishes.

All 12 upload tests passed. No actionable issues found.

Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." · Reviewed by Greptile

@FarhanAliRaza FarhanAliRaza added the bug Something isn't working label Nov 12, 2026 — with ChatGPT Codex Connector
@codspeed

codspeed Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 17 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 146 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing thekarak:fix-upload-chunk-errors (37c5999) with main (2fc174b)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@FarhanAliRaza FarhanAliRaza added the on deck PRs lined up to review / merge next label Nov 19, 2026
# Conflicts:
#	packages/reflex-frontend/src/utils/helpers/upload.js
#	tests/units/reflex_base/client_upload.mjs
@FarhanAliRaza
FarhanAliRaza merged commit 832bfed into reflex-dev:main Nov 19, 2026
168 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working on deck PRs lined up to review / merge next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upload chunk parse errors are never logged: progress === 1 is never true for the streamed upload response

2 participants