Just looking through the Firefox codebase by asserting when we get more than 1 argument to resolve, there's an example pattern which can bite us:
// Return a Promise that resolves when the mutex is free.
return new Promise(unlock => {
// Overwrite the mutex variable with a chained-on, new Promise. The Promise
// we returned to the caller can be called to resolve that new Promise
// and unlock the mutex.
sessionFileIOMutex = sessionFileIOMutex.then(() => {
return new Promise(unlock);
});
});
The issue here being that unlock is actually being called as an executor, and is called with two arguments (resolve and reject)
A similar pattern you could imagine seeing would be
return new Promise(resolve => {
setTimeout(() => someOtherGlobal = new Promise(resolve), 0);
});
Which means mostly that I think we'd want to be cautious about how we decide to opt in; either only take explicit booleans, or only take objects of a particular shape resolve(value, { safeResolveMode: true}))
Just looking through the Firefox codebase by asserting when we get more than 1 argument to resolve, there's an example pattern which can bite us:
The issue here being that
unlockis actually being called as an executor, and is called with two arguments (resolve and reject)A similar pattern you could imagine seeing would be
Which means mostly that I think we'd want to be cautious about how we decide to opt in; either only take explicit booleans, or only take objects of a particular shape
resolve(value, { safeResolveMode: true}))