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

Hangs after error when using Observable #120

Open
unikitty37 opened this issue Oct 15, 2018 · 2 comments
Open

Hangs after error when using Observable #120

unikitty37 opened this issue Oct 15, 2018 · 2 comments

Comments

@unikitty37
Copy link

unikitty37 commented Oct 15, 2018

Let me start out by saying that this is almost certainly something wrong with my code — but the README isn't providing any clues!

When I run the following, I expect to see

✔ good
✖ bad
   → nope
✔ ugly

but what I get is

 ✔ good
 ✖ bad
   ugly

with no spinner next to "ugly" — and it never exits.

    let taskList = []

    const files = ['good', 'bad', 'ugly']
    files.forEach(file => {
      taskList.push({
        title: file,
        exitOnError: false,
        task: () => new Observable(observer => {
          let progress = 0;
          let timer = setInterval(() => {
            if (progress < 100) {
              progress++;
              if (file === 'bad' && progress > 42) {
                observer.error('nope')
              }
              observer.next(`${progress}%`)
            } else {
              clearInterval(timer)
              observer.complete()
            }
          }, 30)
        })
      })
    })
    const tasks = new Listr(taskList)
    tasks.run().catch(err => {
      console.error(err)
    })

What could be going wrong — and is it possible to make the documentation on Observers a bit clearer?

For example, it doesn't actually mention how to throw an error in the Observable at all — the "Failure" example just returns Promise.reject straight off, and replacing the observer.error('nope') with return Promise.reject('nope') results in an infinite loop of UnhandledPromiseRejectionWarnings.

@guyisra
Copy link

guyisra commented Mar 12, 2019

did you manage to solve this?

@unikitty37
Copy link
Author

Afraid not — I ended up having to replace listr with ora in order to get the project working.

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