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

Can’t catch the 'All given promises failed' error. #86

Open
chrism opened this issue Aug 15, 2020 · 4 comments
Open

Can’t catch the 'All given promises failed' error. #86

chrism opened this issue Aug 15, 2020 · 4 comments
Labels

Comments

@chrism
Copy link

chrism commented Aug 15, 2020

Hi, I’m using this approach to load my audio stream, which I took from this comment.
#36 (comment)

this.hifi.load([{ url: 'audio-url', mimeType: 'audio/mime'}])
.then(({ sound }) => {
  console.log('loaded sound', sound);
})
.catch(error => {
  console.log('FROM CATCH', error);
})
.finally(() => {
  console.log('finally')
});

When one of the audio streams in the array works, this works great.

A problem arises though if none of the sources are working.

The catch does log the error message, but there’s still an additional uncaught promise error—which looks to be coming from promise-race.

This output (with debug: true in the config)

ember-hifi                  |  given urls: http://not-audio.com/url
hifi-cache                  |  cache miss for http://not-audio.com/url
Could not determine mime type for http://not-audio.com/url
Attempting to play urls with an unknown mime type can be bad for performance. See documentation for more info.
Could not determine mime type for http://not-audio.com/url
Attempting to play urls with an unknown mime type can be bad for performance. See documentation for more info.
Attempting to play urls with an unknown mime type can be bad for performance. See documentation for more info.
ember-hifi                  |  Compatible connections for http://not-audio.com/url: NativeAudio, HLS, Howler
ember-hifi                  |  TRYING: [Native Audio] -> http://not-audio.com/url
not-audio.com/url:1 GET http://not-audio.com/url net::ERR_NAME_NOT_RESOLVED
ember-hifi                  |  FAILED: [Native Audio] -> Audio source format is not supported. (http://not-audio.com/url)
ember-hifi                  |  TRYING: [HLS] -> http://not-audio.com/url
xhr-loader.js:82 GET http://not-audio.com/url net::ERR_NAME_NOT_RESOLVED
ember-hifi                  |  FAILED: [HLS] -> manifestLoadError (http://not-audio.com/url)
ember-hifi                  |  TRYING: [Howler] -> http://not-audio.com/url
xhr-loader.js:82 GET http://not-audio.com/url net::ERR_NAME_NOT_RESOLVED
ember-hifi                  |  FAILED: [Howler] -> No codec support for selected audio sources. (http://not-audio.com/url)
ember-hifi                  |  All promises failed:
ember-hifi                  |  Native Audio: Audio source format is not supported.
ember-hifi                  |  HLS: manifestLoadError
ember-hifi                  |  Howler: No codec support for selected audio sources.
load-aro                    |  _findFirstPlayableSound took 1065ms
**FROM CATCH Error: [ember-hifi] URL Promise failed because: All given promises failed.**
    at hifi.js:223
    at invokeCallback (rsvp.js:493)
    at publish (rsvp.js:476)
    at publishRejection (rsvp.js:412)
    at rsvp.js:19
    at invoke (backburner.js:338)
    at Queue.flush (backburner.js:229)
    at DeferredActionQueues.flush (backburner.js:426)
    at Backburner._end (backburner.js:960)
    at Backburner._boundAutorunEnd (backburner.js:629)
**finally**
promise-race.js:43 Uncaught (in promise) Error: All given promises failed.
    at promise-race.js:43
    at invokeCallback (rsvp.js:493)
    at publish (rsvp.js:476)
    at publishRejection (rsvp.js:412)
    at rsvp.js:19
    at invoke (backburner.js:338)
    at Queue.flush (backburner.js:229)
    at DeferredActionQueues.flush (backburner.js:426)
    at Backburner._end (backburner.js:960)
    at Backburner._boundAutorunEnd (backburner.js:629)

I’d really like to find a way to suppress this error but I’m a bit lost as I feel like it should have already been caught by the load() promise catch?

Thanks for any help I’m struggling a bit with the docs on this.

@jkeen jkeen added the bug label Oct 6, 2020
@jkeen
Copy link
Contributor

jkeen commented Oct 6, 2020

Hey @chrism, looks like this is a legit bug with hifi that nobody has caught until now.

I tried stepping through the code to see what was going on last night, but couldn't yet find what's throwing the error.

@jkeen
Copy link
Contributor

jkeen commented Sep 7, 2021

@chrism This is still an issue in ember-hifi, but I will report that the fork of hifi I made called ember-stereo has greatly improved error handling and no longer suffers from this issue. Check out the changes at http://ember-stereo.com

@chrism
Copy link
Author

chrism commented Sep 9, 2021

Oh wow @jkeen thanks for the heads up.

In the end I'm using just howler and some custom code, but Ember Stereo looks like it could be a great upgrade.

Going to take a proper look and give it a try.

Thanks again!

@Glarregle
Copy link

Glarregle commented Jul 26, 2022

If anyone comes to this issue, I could solve it like this:

I added a fallback for source:

  get sources() {
    return [
      {
        url: myRealSrc,
        mimeType: myRealMime,
      },
      {
        url: '/assets/empty.mp3',
        mimeType: 'audio/mpeg',
      },
    ];
  }

Then in the load promise, I could throw and catch my own error:

    const { sound } = await this.hifi.load(this.sources);

    if (sound.url === '/assets/empty.mp3') {
      throw 'Given source should succeed';
    }

And on willDestroy() hook, I had to remove it from cached sounds:

willDestroy() {
  super.willDestroy(...arguments);
  if (this.srcErr) {
    this.hifi.soundCache.reset();
  }
 }

I'm migrating to [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants