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

1.1.2 onDownloadProgress callback function parameter is not same as 0.27.2, lost target field #5063

Closed
lqzhgood opened this issue Oct 8, 2022 · 10 comments · Fixed by #5227
Closed

Comments

@lqzhgood
Copy link

lqzhgood commented Oct 8, 2022

Describe the bug

axiosJson.get('/msg/msg.json', { 
    onDownloadProgress: function( progress ){
        console.log(progress);
    }
});

in 0.27.2 progress is ProgressEvent
image

in 1.1.2 progress
image

Expected behavior

1.1.2 same as 0.27.2

Environment

  • Axios Version 1.1.2
  • Browser Chrome
  • Browser 105.0.5195.127 64bit
  • OS: Win10
@robsco-git
Copy link

I am running into the same issue. I was accessing srcElement in order to read an actual content length via a custom header in order to present the progress of a gzipped download in Chrome/Edge.

@adapt0
Copy link

adapt0 commented Oct 17, 2022

I also ran into this issue. Was using the target for processing currently received data chunks on the browser/client side.

Per https://stackoverflow.com/questions/58961981/axios-request-with-chunked-response-stream-from-node

        axios.post(
            apiUrl,
            {
                ids: toGrab.map((r) => r.macAddress),
            },
            {
                onDownloadProgress(event) {
                    parseReceived(event.currentTarget.response);
                }
            }
        );

Client makes a request for information from many devices. Server queries requested devices, retrieves per-device information, and chunk encodes reply as a multipart/form back to the client. Client then processes new information as it arrives.

Workaround is to wait for the complete response to arrive before processing can start :(

@kitsunde
Copy link

Similar issue I wanted to log progress only for content/octet-stream but can't do that via onDownloadProgress since there's no response context present. Setting it per-request also doesn't work as I need to poll an endpoint which returns json until it doesn't.

@lugrinder
Copy link

Some issue. I'm using target to parse data that's comes in chunks of data (application/json+streamed), streamed by server as data chunks were available, making app more responsive instead of waiting for all data to be collected. With this method, the client can wait for all data to be collected, or show data to the user as it arrives.

@jasonsaayman
Copy link
Member

Hi 👋

Please try the latest pre-release by running the following:

npm i axios@1.2.0-alpha.1

@IchordeDionysos
Copy link

This change seems to break build on NodeJS ...

Steps to reproduce:

  1. Run npx gts init in an empty folder
    Let it generate the package.json

  2. Run npm install axios

  3. Go to src/index.ts and add import axios from 'axios'; at the top of the file.

  4. Run npm run compile

It will show the following error:

> npm run compile  

> compile
> tsc

node_modules/axios/index.d.ts:275:11 - error TS2304: Cannot find name 'ProgressEvent'.

275   event?: ProgressEvent;
              ~~~~~~~~~~~~~


Found 1 error in node_modules/axios/index.d.ts:275

A bit of research did reveal that a similar bug was reported back in 2020:
#3219

--

@jasonsaayman @DigitalBrainJS could you take a look into this?

@DigitalBrainJS
Copy link
Collaborator

@IchordeDionysos I'll deal with this tomorrow. This seems to have happened more than once, people forget that Axios is cross-platform and add PRs with strict DOM-related types https://github.com/axios/axios/pull/4675/files.

@IchordeDionysos
Copy link

@IchordeDionysos
Copy link

@DigitalBrainJS yes it's understandable ☺️

@vmalyi
Copy link

vmalyi commented Dec 5, 2022

@DigitalBrainJS, hey folks, any reason why this fix didn't get it into the recent 1.2.0 release?

When can we expect otherwise?

Thanks!

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 a pull request may close this issue.

9 participants