Skip to content

fix(android): avoid double-counting upload progress - #57870

Open
fallintoplace wants to merge 2 commits into
react:mainfrom
fallintoplace:fix/android-progress-request-body-counting
Open

fix(android): avoid double-counting upload progress#57870
fallintoplace wants to merge 2 commits into
react:mainfrom
fallintoplace:fix/android-progress-request-body-counting

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

ProgressRequestBody wraps its sink in FilterOutputStream. On Android, the bulk write implementation can dispatch through write(Int) for every byte. The bulk override then increments the counter again, so upload progress can report more bytes than the request length.

This changes the bulk write to delegate directly to the wrapped stream before incrementing the counter once. The old CountingOutputStream implementation used the same direct delegation.

Changelog:

[ANDROID] [FIXED] - Avoid double-counting upload progress for bulk writes.

Test plan

  • Added a regression test for an 8 KiB bulk write.
  • Verified the payload is unchanged.
  • Verified progress never exceeds the content length and finishes with done = true.
  • Ran the full com.facebook.react.modules.network.* unit-test package.
  • Ran ReactAndroid:ktfmtCheck.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 9, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant