BaristaLabs/BaristaCore

Resolving pending promises on Promise.Race prevents useful scenarios

JesperTreetop opened this issue · 1 comments

When using Promise.Race, it immediately resolves the promise. I imagine this is to resolve the race's own return promise. I'm trying to race a promise created from user code with one created from my code, set to reject after a time interval, in order to provide a timeout for the user code running in the promise, or finish promises that were created but never neither resolved nor rejected, akin to this article.

Just a quick update -- have been looking into this and see that you're absolutely right in that this does prevent a nice co-existence of tasks with promises. I'm looking at ways of fixing this, but still ensuring that the single-threaded model of the chakra engine is sustained.

The task's continuation needs to be ensured to be run on the same thread that the chrakracore engine is bound to, and I'm figuring out how to accomplish this.