Skip to content

Stream sometimes hands after updating from v0.24 to v0.26 #4536

@tabarra

Description

@tabarra

Describe the bug

Since updating from v0.24 to v0.26, downloading files via stream started hanging, which also seems to not even respect the timeout property.

To Reproduce

The code below is shipped in a software, and users have been reporting this issue since I updated.
Unfortunately I did not manage to reproduce it on my computer, and some users have 100% repro rate.
The code below prints before stream promise but never after stream.
For reference, I'm actually downloading zip files from the github API, so I do not suspect it is some issue with the source.

//Downloading file
const res = await axios({
    method: 'get',
    url: 'https://api.github.com/repos/axios/axios/zipball/v0.26.0',
    responseType: 'stream',
    timeout: 150e3, //doesn't seem to work
});

console.log('before stream promise');
await new Promise((resolve, reject) => {
    const outStream = fs.createWriteStream('./something.zip');
    res.data.pipe(outStream);
    outStream.on('finish', resolve);
    outStream.on('error', reject); // I did not forget this :P
});
console.log('after stream'); //never gets printed

Expected behavior

I expect it to either:

  • Save the something.zip file; or
  • Throw an error in case something goes wrong; or at least
  • Throw an error after the 150s timeout defined.

Environment

  • Axios Version v0.26
  • Node.js Version 16.9.1
  • OS: Happened both on Windows Server as well as o Linux

Additional context/Screenshots

I suspect this is related to either #3916 or #3967.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions