fix(http): flush download progress before stream close by cyphercodes · Pull Request #11040 · axios/axios · GitHub
Skip to content

fix(http): flush download progress before stream close#11040

Open
cyphercodes wants to merge 1 commit into
axios:v1.xfrom
cyphercodes:fix-6878-download-progress-order
Open

fix(http): flush download progress before stream close#11040
cyphercodes wants to merge 1 commit into
axios:v1.xfrom
cyphercodes:fix-6878-download-progress-order

Conversation

@cyphercodes

@cyphercodes cyphercodes commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the Node HTTP adapter ordering where the final throttled onDownloadProgress callback could run after a streamed response emitted close.

Linked issue

Closes #6878

Changes

  • Schedule HTTP adapter progress callbacks with Node's next-tick queue so a final flush runs before stream close listeners.
  • Add a regression test for streamed downloads with throttled progress events.
  • Add the fix to the pre-release changelog.

Checklist

  • Tests added or updated
  • Docs/types updated if public API changed (N/A, no public API change)
  • No breaking changes

🏄


Summary by cubic

Fixes Node HTTP adapter ordering so the final onDownloadProgress fires before a streamed response emits close, avoiding late progress after consumers see the stream closed. Uses process.nextTick to schedule the final flush.

Description

  • Summary of changes
    • Schedule progress callbacks with process.nextTick (fallback to utils.asap).
    • Allow asyncDecorator to accept a scheduler and pass it from the HTTP adapter.
    • Add a regression test for throttled download progress with streams.
    • Update pre-release changelog.
  • Reasoning
    • Prevents a final throttled progress callback from running after close, which was confusing and incorrect.
  • Additional context

Docs

  • No docs changes needed. If we document progress behavior, note that onDownloadProgress will not fire after stream close. Update /docs/ accordingly if relevant.

Testing

  • Added a unit test ensuring the last progress event is emitted before close and none fire after.
  • No other tests modified.

Semantic version impact

  • Patch: bug fix with no API or behavior-breaking changes.

Written for commit 50faae5. Summary will update on new commits.

Review in cubic

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

Confidence score: 5/5

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

Re-trigger cubic

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.

onDownloadProgress occurred after request solved

1 participant