Skip to content

fix(progress): guard malformed XHR upload events#10868

Merged
jasonsaayman merged 2 commits into
axios:v1.xfrom
rkdfx:fix/6928-onuploadprogress-undefined-event
May 9, 2026
Merged

fix(progress): guard malformed XHR upload events#10868
jasonsaayman merged 2 commits into
axios:v1.xfrom
rkdfx:fix/6928-onuploadprogress-undefined-event

Conversation

@rkdfx

@rkdfx rkdfx commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

onUploadProgress crashes with Cannot read property 'loaded' of undefined
on React Native 0.79+ because progressEventReducer reads e.loaded
without guarding the event shape. This adds a defensive check.

Linked issue

Closes #6928

Changes

  • lib/helpers/progressEventReducer.js: skip throttled callback when
    the incoming event is missing or loaded is not numeric.
  • tests/unit/helpers/progressEventReducer.test.js: cover undefined,
    null, {}, non-numeric loaded, and recovery on a subsequent
    valid event.

Checklist

  • Tests added or updated (or N/A with reason)
  • Docs / types updated if public API changed (index.d.ts and index.d.cts)
  • No breaking changes (or called out explicitly above)

Summary by cubic

Fixes a crash in onUploadProgress on React Native 0.79+ by guarding malformed XHR progress events in progressEventReducer. Prevents "Cannot read property 'loaded' of undefined" and safely ignores invalid events.

Description

  • Summary of changes
    • Skip progress callbacks when the event is missing or loaded is not a number.
    • Continue normal processing for the next valid event.
  • Reasoning
    • RN 0.79+ can emit undefined/malformed progress events; accessing e.loaded crashed.
  • Additional context

Docs

Add a troubleshooting note in /docs/ for React Native uploads: onUploadProgress ignores malformed events to avoid crashes.

Testing

  • Added unit tests for undefined, null, {}, and non-numeric loaded.
  • Verified no callbacks for malformed events and recovery on a subsequent valid event.

Semantic version impact

  • Patch: bug fix with no API or behavior changes for valid inputs.

Written for commit b47d238. Summary will update on new commits.

Signed-off-by: Ravi <13908473+rkdfx@users.noreply.github.com>
@rkdfx rkdfx requested a review from jasonsaayman as a code owner May 8, 2026 22:34

@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 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@jasonsaayman jasonsaayman added priority::medium A medium priority commit::fix The PR is related to a bugfix labels May 9, 2026
@jasonsaayman jasonsaayman merged commit 4094886 into axios:v1.x May 9, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::fix The PR is related to a bugfix priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Axios onUploadProgress error - Cannot read property 'loaded' of undefined

2 participants