question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

invalid 'actionAsync' context when promises resolve at the same time in different actionAsync

See original GitHub issue

Im 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
xaviergonzcommented, Apr 5, 2020

v5.5.6

2reactions
xaviergonzcommented, Feb 20, 2020

Thanks, just made a PR that should solve this

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found