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

Reflux actions throw an error in the console when they fail #4

Open
spoike opened this issue Oct 13, 2015 · 3 comments
Open

Reflux actions throw an error in the console when they fail #4

spoike opened this issue Oct 13, 2015 · 3 comments
Labels

Comments

@spoike
Copy link
Member

spoike commented Oct 13, 2015

Originally posted by @liady reflux/refluxjs#403 Moved to here since promises have been extracted out of reflux-core and is now in reflux-promise.

Lately I started getting Uncaught (in promise) some-error errors in my console whenever an action failed.
I researched a bit and found out that Reflux creates a promise every time an action is triggered, and if the action fails, the promise rejects and there is no one to catch it. I boiled it down to:

// create an action with completed/failed children
var action = Reflux.createAction({asyncResult:true});

// *** First scenario - throws error *** //
// invoke the action
action();
// somewhere the action has failed
action.failed("some reason"); // throws an error in the console - why??


// *** Second scenario - ok *** //
// invoke the action, but with a catch clause
action().catch(function(){});
// somewhere the action has failed
action.failed("some reason 2"); // this is now ok...

Fiddle here

Seems like every action trigger creates a promise, and that causes this issue when the action fails. I would imagine this would happen only when calling action.triggerPromise explicitly, and not every time.

Currently I have to attach a catch clause to every action trigger in my code to fix this problem. I want my components to just call the actions, not handle their outcome. Is there a way to avoid it? Am I missing something here?

@jfairley
Copy link

👍

@dannyshaw
Copy link

dannyshaw commented Sep 22, 2016

This added catch in the merge had me hunting issues for days... all and any javascript errors (typos, even a throw new Error('error'); within a react render() method that was updated as a result of an async store trigger were being completely swallowed by this line. even adding unhandled error catch was obviously failing.

I think it's GOOD that unhandled errors are reported. swallowing them should be explicitly required by the developer.

@itkach
Copy link

itkach commented Apr 13, 2017

#12 is a nasty change, should have never been merged

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

4 participants