alt icon indicating copy to clipboard operation
alt copied to clipboard

Unhandled promise reject with with async datasource

Open wprater opened this issue 10 years ago • 13 comments

Using the datasource decoration on the store and when the error handler is called, it will callback through the action to the Store, but will also throw Unhandled promise rejection .... Why is this? are we supposed to catch the thrown exception here?

wprater avatar Aug 07 '15 18:08 wprater

I'm not sure, can you post a failing test case?

goatslacker avatar Aug 07 '15 18:08 goatslacker

because you re throw the reject, one will need to catch it in the call to the remote call. seems a bit inconvenient, since you also have the error handling action. perhaps it should be up the implementor to throw in the error handler vs. always throwing in the remote action?

fetch(key) {
      this.getInstance().performFetch(key).catch((err) => {
        // need to catch here since the rejection is re-thrown
        console.error(err)
      });
}

fetchError(err) {
    // this is the rejection handler, we could choose to re-throw here instead?
}

wprater avatar Aug 07 '15 19:08 wprater

The reason I'm throwing there is so that failed actions are marked as rejected.

goatslacker avatar Aug 26 '15 23:08 goatslacker

ahh, are you handling that exceptions somewhere?

On Wed, Aug 26, 2015 at 4:48 PM Josh Perez [email protected] wrote:

The reason I'm throwing there is so that failed actions are marked as rejected.

— Reply to this email directly or view it on GitHub https://github.com/goatslacker/alt/issues/447#issuecomment-135207117.

wprater avatar Aug 27 '15 01:08 wprater

Well for Render for example it's needed so you can fail the entire Promise.all call

goatslacker avatar Aug 27 '15 01:08 goatslacker

Is there any progress on this to provide some way to catch those rejections so they don't show up as unhandled?

robertvansteen avatar Nov 17 '15 16:11 robertvansteen

@reauv you can catch it when you call it https://github.com/goatslacker/alt/issues/447#issuecomment-128798413 but that's the only way I've found. a bit cumbersome.

wprater avatar Nov 17 '15 21:11 wprater

+1 It's impossible to handle these rejections :(

ykka avatar Nov 19 '15 17:11 ykka

+1 It's impossible to handle this situation :(

lianyzhou avatar Dec 02 '15 10:12 lianyzhou

+1

gogoout avatar Dec 08 '15 03:12 gogoout

+1

nowarkdev avatar Jan 25 '16 15:01 nowarkdev

Thanks for the report, @wprater! We are running into this problem as well.

Does anyone know if Is this resolved in alt 0.18.x?

coopy avatar Feb 27 '16 00:02 coopy

AFAIK this is not resolved in 0.18.x, I'm running 0.18.2 and it has this issue.

Does anyone have a workaround for this where we can use the error handler we've defined but not have an uncaught promise?

berfarah avatar Mar 16 '16 16:03 berfarah