Why doesn't await Synchronize blocking work in this code?

wanted to implement a 3 s delay in downloading each image, but did not find out the reason why await did not take effect. The code is as follows

axios.get(imgSrc, {
                responseType: "stream"
         }).then(async res => {
            console.log("")
         await pipeSync(res,dirName,type)
            currentNumberPP;
            console.log(currentNumber);
});



function pipeSync(res,dirName,type){
    return new Promise(function (resolve, reject) {
       
           res.data.pipe(fs.createWriteStream(dirName + "/" + (new Date().getTime())+"."+type));
           setTimeout(resolve,3000);
    });
 }
 
 
Mar.23,2021

the reason is that async is only a pseudo Synchronize, which can only guarantee blocking in the current function, but cannot cause global blocking that affects the download queue


.

pipe is not Synchronize

const stream = fs.createWriteStream(dirName + "/" + (new Date().getTime())+"."+type);
stream.on('error', reject);
stream.on('finish', () => {
   // , 3 resolve
   setTimeout(resolve,3000);
});

// 
res.data.pipe(stream);
Menu