Skip to content

fix(xhr): flush final progress during the live loadend dispatch - #11121

Merged
jasonsaayman merged 5 commits into
axios:v1.xfrom
ostapondo:fix/stream-chunk-throttle
Aug 13, 2026
Merged

jasonsaayman merged 5 commits into
axios:v1.xfrom
ostapondo:fix/stream-chunk-throttle

Conversation

@ostapondo

@ostapondo ostapondo commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Axios 1.7.0 introduced throttled progress delivery. Timer-deferred XHR progress callbacks therefore receive an event whose DOM dispatch has already ended, so event.currentTarget is null. Consumers that incrementally read responseText through currentTarget can miss every deferred chunk, reproducing #6796 most visibly in Firefox and Safari.

This change force-delivers one final onDownloadProgress callback from the still-dispatching successful XHR loadend event. That gives cumulative readers a live target and the complete response while preserving the established behavior of upload, stream-error, abort-reason, and failed-download flushes. XHR implementations without onloadend instead replay their pending progress event through the legacy ready-state fallback.

The forced delivery path is explicit rather than inferred from a flush argument's shape. A final callback can also throw or synchronously cancel the request without leaving settlement pending or causing the XHR handler to dereference a cleared request.

Playwright verification covers Chromium, Firefox, and WebKit. A currentTarget-based reader that previously received only the initial part of a fast stream now recovers the complete payload.

Linked issue

Closes #6796

Changes

  • lib/helpers/throttle.js: keeps ordinary flush argument-agnostic and adds an explicit flushWith function for replacement arguments.
  • lib/helpers/progressEventReducer.js: exposes that explicit forced-delivery function without inspecting stream errors or cancellation reasons.
  • lib/adapters/xhr.js: force-delivers only the successful final download event, replays pending progress in the eventless ready-state fallback, stops cleanly after synchronous cancellation, and preserves prior failure/upload flush behavior.
  • tests/browser/progress.browser.test.js: uses real EventTarget/ProgressEvent semantics and adds eight browser regression tests covering live final delivery, complete streamed reads, the ready-state fallback, cancellation, listener exceptions, status-zero failures, upload failures, and deferred event.target behavior.
  • tests/unit/helpers/progressEventReducer.test.js and tests/unit/helpers/throttle.test.js: cover explicit forced delivery, pending-event replay, loaded-shaped errors, throwing getters, and the throttle tuple contract.
  • PRE_RELEASE_CHANGELOG.md and PRE_RELEASE_DOCS.md: record the download-only guarantee and retained failure semantics.

Testing

  • npx eslint lib/adapters/xhr.js lib/helpers/progressEventReducer.js lib/helpers/throttle.js
  • npm run test:vitest:unit — 58 files, 1,045 tests passed
  • npm run test:vitest:browser:headless -- tests/browser/progress.browser.test.js — Chromium, Firefox, and WebKit; 42 tests passed

Checklist

  • Tests added or updated
  • Deferred documentation recorded in PRE_RELEASE_DOCS.md; no public type change
  • No breaking API change

🏄

@ostapondo
ostapondo requested a review from jasonsaayman as a code owner August 3, 2026 11:01

@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.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread lib/adapters/xhr.js Resolved
@greptile-apps

greptile-apps Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This change delivers the final XHR download progress callback while the loadend event still has a live target, retains pending progress for the legacy ready-state completion path, and ensures synchronous cancellation or listener exceptions do not leave a request unsettled.

The focused XHR repro showed the previous revision lost the final loaded=8 fallback update, while this revision delivers it. The same repro confirmed live-target delivery, cancellation rejection, and settlement after a throwing final listener. Browser progress coverage passed 14/14 tests in headless Chromium, and adjacent XHR adapter coverage passed 7/7 tests.

Confidence Score: 5/5

The PR is safe to merge; no blocking failure remains.

The focused browser and XHR adapter checks passed, and the exercised completion, fallback, cancellation, and listener-exception paths behaved as intended.

T-Rex T-Rex Logs

What T-Rex did

  • Ran the authored EventTarget-based XHR repro against the parent revision 81f0b90 and observed the ready-state fallback delivered only loaded=4.
  • Re-ran the same repro at the PR tip and confirmed live loadend delivery, fallback replay, synchronous abort rejection, and settlement after a throwing final listener all passed.
  • Executed the focused browser progress suite in headless Chromium, which passed all 14 tests.
  • Ran the adjacent XHR adapter unit suite, which passed all 7 tests.
  • Uploaded a narrow repro script and confirmed that no production files were modified by the change set.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (6): Last reviewed commit: "fix(xhr): preserve fallback download pro..." | Re-trigger Greptile

Comment thread lib/adapters/xhr.js Resolved
@jasonsaayman jasonsaayman added the commit::fix The PR is related to a bugfix label Aug 4, 2026
ostapondo and others added 4 commits August 9, 2026 12:13
Throttled progress deliveries replay events whose dispatch has already
finished, so event.currentTarget is null and listeners reading incremental
data from it lose every chunk delivered through the throttle timer or the
loadend flush. Flush with the still-dispatching loadend event instead, so a
final delivery with the complete transfer state always reaches the listener
while the event has a live target.

The reducer only treats a flush argument with a numeric loaded field as a
fresh event; stream errors and abort reasons passed by other adapters keep
replaying the last pending event.
The live loadend flush runs user code before settle(), so a throwing
onDownloadProgress left the promise pending and cancellation listeners
attached. Guard the flush and rethrow asynchronously, matching how
listener errors already surface on the throttle timer path.

@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.

All reported issues were addressed across 8 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread lib/adapters/xhr.js Resolved
@jasonsaayman
jasonsaayman merged commit d8a919f into axios:v1.x Aug 13, 2026
27 checks passed
markharding pushed a commit to futo-org/Harbor that referenced this pull request Oct 16, 2026
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [axios](https://axios-http.com) ([source](https://github.com/axios/axios)) | [`1.18.1` → `1.20.0`](https://renovatebot.com/diffs/npm/axios/1.18.1/1.20.0) | ![age](https://developer.mend.io/api/mc/badges/age/npm/axios/1.20.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/axios/1.18.1/1.20.0?slim=true) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/99) for more information.

---

### Release Notes

<details>
<summary>axios/axios (axios)</summary>

### [`v1.20.0`](https://github.com/axios/axios/releases/tag/v1.20.0)

[Compare Source](axios/axios@v1.19.0...v1.20.0)

#### v1.20.0 — August 19, 2026

This release hardens runtime option handling, adds RFC 9110 status-code aliases, fixes Node.js and XHR reliability issues, and refreshes project tooling and documentation.

#### ⚠️ Breaking Changes & Deprecations

- HTTP Status Naming: Added ContentTooLarge (413) and UnprocessableContent (422), while retaining PayloadTooLarge and UnprocessableEntity as backward-compatible deprecated aliases. ([#&#8203;11082](axios/axios#11082))

#### 🔒 Security Fixes

- Runtime Option Handling: Hardened behavioral configuration reads against shared and foreign prototype pollution and normalized unsafe interceptor replacement objects. This also clarifies Fetch redirect and custom implementation behavior, HTTP/2 DNS and proxy handling, CIDR-based NO_PROXY matching, and malformed data URI rejection; see the PR for documented compatibility effects. ([#&#8203;11141](axios/axios#11141))

#### 🐛 Bug Fixes

- Interceptor Lifecycle: Prevented unbounded handler-array growth by trimming trailing ejected interceptors without changing iteration semantics, and kept interceptor operations safe when the public handlers field is nullish. ([#&#8203;11087](axios/axios#11087), [#&#8203;11118](axios/axios#11118))
- Request Error Preservation: Prevented custom Error.prepareStackTrace implementations that return non-string values from replacing the original request failure with an unrelated TypeError. ([#&#8203;11109](axios/axios#11109))
- XHR Reliability: Navigation-canceled requests now reject with ECONNABORTED instead of resolving with status 0, while successful downloads flush their final progress callback during the live loadend dispatch. ([#&#8203;11094](axios/axios#11094), [#&#8203;11121](axios/axios#11121))
- Node.js Socket Memory: Removed request-context retention from per-socket error listeners, preventing completed response data from being pinned for the lifetime of pooled keep-alive sockets. ([#&#8203;11091](axios/axios#11091))
- Core Methods and HTTP Errors: Prevented structural method-header buckets from leaking into outgoing headers, standardized invalid DNS lookup and httpVersion failures as AxiosError.ERR_BAD_OPTION_VALUE, and corrected the timeoutErrorMessage merge strategy. ([#&#8203;11096](axios/axios#11096))

#### 🔧 Maintenance & Chores

- Dependencies: Updated fast-uri, postcss, js-yaml, mocha, development-tooling groups, and GitHub Actions dependencies. ([#&#8203;11092](axios/axios#11092), [#&#8203;11098](axios/axios#11098), [#&#8203;11099](axios/axios#11099), [#&#8203;11106](axios/axios#11106), [#&#8203;11107](axios/axios#11107), [#&#8203;11122](axios/axios#11122), [#&#8203;11123](axios/axios#11123), [#&#8203;11126](axios/axios#11126), [#&#8203;11127](axios/axios#11127), [#&#8203;11133](axios/axios#11133), [#&#8203;11140](axios/axios#11140), [#&#8203;11143](axios/axios#11143), [#&#8203;11144](axios/axios#11144))
- Documentation: Applied the v1.19.0 documentation updates, added the missing fs import to the README stream example, introduced localized global search, and repaired the interceptor test link. ([#&#8203;11101](axios/axios#11101), [#&#8203;11113](axios/axios#11113), [#&#8203;11097](axios/axios#11097), [#&#8203;11119](axios/axios#11119))
- Sponsorship: Updated sponsorship links and data and added ScrapingBee as a sponsor. ([#&#8203;11124](axios/axios#11124), [#&#8203;11136](axios/axios#11136), [#&#8203;11137](axios/axios#11137))
- CI and Release: Switched ESM smoke tests to locked dependencies and synchronized package and runtime version metadata for v1.20.0. ([#&#8203;11128](axios/axios#11128), [#&#8203;11152](axios/axios#11152))

#### 🌟 New Contributors

We are thrilled to welcome our new contributors. Thank you for helping improve axios:

- [@&#8203;yens1](https://github.com/yens1) ([#&#8203;11109](axios/axios#11109))
- [@&#8203;Sasireddy001](https://github.com/Sasireddy001) ([#&#8203;11113](axios/axios#11113))
- [@&#8203;ari-token-security](https://github.com/ari-token-security) ([#&#8203;11094](axios/axios#11094))
- [@&#8203;timothyokooboh](https://github.com/timothyokooboh) ([#&#8203;11097](axios/axios#11097))
- [@&#8203;gi9439041-png](https://github.com/gi9439041-png) ([#&#8203;11119](axios/axios#11119))
- [@&#8203;Hashim1999164](https://github.com/Hashim1999164) ([#&#8203;11082](axios/axios#11082))
- [@&#8203;v-dev-cl](https://github.com/v-dev-cl) ([#&#8203;11091](axios/axios#11091))
- [@&#8203;r0h1tb](https://github.com/r0h1tb) ([#&#8203;11118](axios/axios#11118))
- [@&#8203;ostapondo](https://github.com/ostapondo) ([#&#8203;11121](axios/axios#11121))

Full Changelog (<axios/axios@v1.19.0...v1.20.0>)

### [`v1.19.0`](https://github.com/axios/axios/blob/HEAD/CHANGELOG.md#v1190--July-22-2026)

[Compare Source](axios/axios@v1.18.1...v1.19.0)

This release raises the form-data security floor, adds configuration and type-system capabilities, and fixes NO_PROXY matching, interceptor errors, progress reporting, and serialization edge cases.

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - "before 9am on tuesday"
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xMzMuMCIsInVwZGF0ZWRJblZlciI6IjQ0LjE2NC41IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJyZW5vdmF0ZSJdfQ==-->

Reviewed-on: https://code.futo.org/harbor/harbor/pulls/1808
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Axios version >= 1.7.0 Streaming Chunk Parsing Issue in Safari and Firefox

2 participants