asyncResult action call gives an "Uncaught (in promise)" error
See original GitHub issueWhen I call an asyncResult action and when the triggered async process sends back an error (for example: “401 unauthorized”), everything works fine but I get another error in the console: “Uncaught (in promise) … PublisherMethods.js:168”:
var Reflux = require('reflux');
var someActions = Reflux.createActions({
doThis: {
asyncResult: true
},
// ...
});
someActions.doThis.listen(function (arg) {
someAsyncProcess(arg)
.then(this.completed)
.catch(this.failed);
});
// elsewhere in the app:
someActions.doThis(arg);
// -> if someAsyncProcess sends back an error, another error in the console:
// "Uncaught (in promise) ... PublisherMethods.js:168"
Am I doing it wrong, or is there a bug in the asyncResult actions ?
Issue Analytics
- State:
- Created 9 years ago
- Comments:21 (1 by maintainers)
Top Results From Across the Web
Uncaught (in promise) Error: When called with an action of type
The request is okay and I can see the data when I console.log in the action creator but for some reason the reducer...
Read more >JavaScript Mapping for Operations - Ice
The AsyncResult object returned by an Ice API call encapsulates the state of the asynchronous invocation. In other Ice language mappings, the AsyncResult...
Read more >Async/await in TypeScript - LogRocket Blog
It provides an easy interface to read and write promises in a way that makes them appear synchronous. An async/await will always return...
Read more >Asynchronous programming in Office Add-ins - Microsoft Learn
If your call fails you can use the AsyncResult.error property to access ... API provides the Office.select function to support the promises ......
Read more >Promises - Error Handling - Beginner JavaScript - Wes Bos
When a promise goes awry, and you want to bail on it, you can call the reject function. ... catching the uncaught promise...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was running into this as well and it was driving me batty. I’m pretty sure I know what the issue is, but I’m not sure what the correct solution is. However, there is a workaround you can put in your code to at least prevent the error from popping up in the console.
The key bit being that catch there at the end.
The problem is that when the “doThis” action is called a promise is setup that listens for “doThis.failed” to be called. Of course, when your “someAsyncProcess” promise gets rejected, the “doThis.failed” gets called as expected. However, that also triggers a reject on the promise that Reflux sets up in the generated function for the action. Because there isn’t a catch setup for that, the promise API throws an error.
I’m still not quite sure I understand why reject is called when the failed child action is triggered as it seems like it should work the other way around. I’m sure there is a good reason for it.
Hi All,
I was struggling with the same issue but I got it fixed by making minor change. Add async : false in all AJAX get requests. Consider the code below:
type : “GET”, url : “/someUrl/”, dataType : ‘json’, async : false,