BaristaLabs / BaristaCore

BaristaCore is a framework for providing a serverless platform using ChakraCore and .Net Core
MIT License
28 stars 3 forks source link

Resolving pending promises on Promise.Race prevents useful scenarios #60

Open JesperTreetop opened 6 years ago

JesperTreetop commented 6 years ago

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.

Oceanswave commented 6 years ago

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.