invalid 'actionAsync' context when promises resolve at the same time in different actionAsync
See original GitHub issueIm getting the following error when i run the code below
mobx-utils.module.js:6 Uncaught (in promise) Error: [mobx-utils] invalid 'actionAsync' context when finishing action 'actionAsync1'. an action context for 'actionAsync2' was found instead. did you await inside an 'actionAsync' without using 'task(promise)'? did you forget to await the task?
const r = new Promise(resolve => {
setTimeout(() => {
resolve(null);
}, 1000);
});
const actionAsync1 = actionAsync("actionAsync1", async () => {
await task(r);
});
const actionAsync2 = actionAsync("actionAsync2", async () => {
await task(r);
});
actionAsync1();
actionAsync2();
It happens with both the following version combinations:
"mobx": "4.15.4",
"mobx-utils": "5.5.3",
"mobx": "5.15.4",
"mobx-utils": "5.5.3",
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Is it safe to resolve a promise multiple times? - Stack Overflow
I faced the same thing a while ago, indeed a promise can be only resolved once, another tries will do nothing (no error,...
Read more >Using Route Guards, Actions and Web Components
This action function can receive a context and commands as parameters: ... component: 'lit-component', action: async (context: Context, ...
Read more >Scala Async - 2.8.x - Play Framework
Internally, Play Framework is asynchronous from the bottom up. Play handles every request in an asynchronous, non-blocking way. The default configuration is ...
Read more >Promise - JavaScript - MDN Web Docs
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
Read more >25. Promises for asynchronous programming - Exploring JS
Resolving a Promise has different effects, depending on what value you are ... and that chaining Promises won't starve other tasks of processing...
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 Free
Top 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
v5.5.6
Thanks, just made a PR that should solve this