Re: miniSphere 5.1.1
Reply #2193 –
@Rhuan and I have been working on a great new debugging aid which is coming in miniSphere 5.2. Historically, rejecting a promise in miniSphere would crash the specific promise chain it occurs in, but otherwise go unnoticed. This can cause some very strange and difficult-to-understand behavior in heavily asynch code, especially in codebases where async functions are used heavily (like my own Spectacles project). To illustrate the problem, take this code:
async function pig()
{
SSj.log("Oh no, I think I'm going to get eaten by the pig...");
throw new Error("PIG!!!");
SSj.log("The pig totally ate me, you guys!");
}
pig();
SSj.log("The pig is coming to eat EVERYTHING.");
This will hit all the SSj.log() calls except for the second one in pig(), and terminate normally. That happens because pig(), being an unawaited async call, crashes at the throw without affecting the primary (i.e. synch) code path; the promise representing its return value is simply rejected sight unseen.
Broken promises are annoying and difficult to debug, but thanks to @Rhuan's hard work getting promise rejection tracking into ChakraCore, in miniSphere 5.2, the code above will be detected as a runtime error (by the event loop) and generate an error screen with a stack trace the same way an exception in synch code does. This will make debugging async code much more pleasant.