sindresorhus / ora

Elegant terminal spinner
MIT License
9.15k stars 271 forks source link

Spinner will freezes when I use Ora in my async functio. #142

Closed fuergaosi233 closed 4 years ago

fuergaosi233 commented 4 years ago
async function loader(fn,process,...args){
// process:{start,loding,sucess} runtime info 
  const spinner =  ora(process.start||`start`).start();
  spinner.text = `${process.loding||'loding'}`;
  try{
    let res = await fn(...args)
    spinner.succeed(process.success||`success`)
    return res 
  }catch(err){
    spinner.fail(process.fail||'fail');
    throw err;
  }
}

When i useloader to run async function , the spinner will freezes likes this: image So what should I do for solve this problem.

fuergaosi233 commented 4 years ago

I change my sync function to async function then solved it.

sindresorhus commented 4 years ago

This is documented in the readme (at the bottom).