-
Is this a reasonable way to test whether we have promise shortening?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
To clarify your question, does resolving a normal promise to an unresolved handled promise cause eventual-sends to the normal promise to get handled by the handled promise's unresolved-handler? For the eventual-send proposal that we wish to get through tc39, yes. For any possible shim implementation on any current JS engine (including v8 and xs), no. As a result, those messages fail to be pipelined. Currently, to get reliable pipelining of messages eventually-sent to unresolved remote promises, you must carefully ensure that there are no normal promises between the immediate message target and the vat boundary. This is hard but not impossible. Did we hit a motivating case? |
Beta Was this translation helpful? Give feedback.
-
If we could have hooks in the engine to ultimately discover when a result promise (like the return value of a native async function) adopts another promise (like an explicit A strawman API would be something like: class PromiseAdoptionRegistry {
constructor(onAdoption: (adopter: Promise, adoptee: Promise) => void);
registerAdopter(adopter: Promise);
registerAdoptee(adoptee: Promise);
} Then you could do: const adoptionRegistry = new PromiseAdoptionRegistry((adopter, adoptee) => {
assert(adopter === p && adoptee === hp);
console.log('adopted');
});
const hp = new HandledPromise((resolve, reject, resolveWithPresence) => {}, {
applyMethod: (p, name, args) => console.log({ name, args }),
});
adoptionRegistry.registerAdoptee(hp);
let resolveP;
const p = new Promise(r=> { resolveP = r; });
adoptionRegistry.registerAdopter(p);
resolveP(hp); // prints 'adopted', likely in a new turn |
Beta Was this translation helpful? Give feedback.
To clarify your question, does resolving a normal promise to an unresolved handled promise cause eventual-sends to the normal promise to get handled by the handled promise's unresolved-handler?
For the eventual-send proposal that we wish to get through tc39, yes.
For any possible shim implementation on any current JS engine (including v8 and xs), no.
As a result, those messages fail to be pipelined. Currently, to get reliable pipelining of messages eventually-sent to unresolved remote promises, you must carefully ensure that there are no normal promises between the immediate message target and the vat boundary. This is hard but not impossible.
Did we hit a motivating case?