Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress event does not have lengthComputable property #6290

Open
matthew-white opened this issue Mar 11, 2024 · 1 comment
Open

Progress event does not have lengthComputable property #6290

matthew-white opened this issue Mar 11, 2024 · 1 comment

Comments

@matthew-white
Copy link

Describe the bug

I use axios to send requests in the browser. I recently updated from axios v0.22.0, and I'm noticing that onUploadProgress works a little differently from how it did before — enough that I had to change my code. Previously, the onUploadProgress callback was passed a native ProgressEvent. It's now passed an axiosProgressEvent. I like axiosProgressEvent and all the new properties available on it. However, there's one property that the ProgressEvent had that the axiosProgressEvent doesn't: lengthComputable. Previously, my code was using lengthComputable, so I had to change it. That wasn't hard to do, but I didn't realize I had to for a while, as I didn't see this change mentioned in the release notes. Going forward, I'll probably just use the progress property on the axiosProgressEvent, but it would have been nice not to change existing code.

lengthComputable is still accessible via the event property on the axiosProgressEvent, but I think it should also be a top-level property on the axiosProgressEvent. That would make axiosProgressEvent more like a superset of a native ProgressEvent.

To Reproduce

No response

Code snippet

onUploadProgress: (event) => {
  // event no longer has a lengthComputable property.
  console.log(event);
}

Expected behavior

I was expecting the lengthComputable property to continue to exist on the event passed to onUploadProgress. If it's possible, I think it'd be helpful to add lengthComputable to the axiosProgressEvent. Alternatively, this change could be highlighted in the release notes. I think this change was introduced in bdf493c as part of v1.0.0.

Axios Version

1.6.2

Adapter Version

XHR

Browser

No response

Browser Version

No response

Node.js Version

No response

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@DigitalBrainJS
Copy link
Collaborator

DigitalBrainJS commented Apr 28, 2024

The lengthComputable field has been re-added in the new beta, although it doesn't make much sense since it simply checks if total != null.

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

No branches or pull requests

2 participants