marshal: Allow promise stand-ins
See original GitHub issueThe agoric-sdk kernel needs to transform marshaled messages, preferably while respecting their encoding by using standard marshal interfaces. But doing so effectively requires opaque treatment of remotables and promises, which is not currently possible with smallcaps because it maintains an encoding-level distinction between the two classes and requires that the latter correspond with actual ECMAScript Promise instances.
Proposed solution: Update passStyleOf
to support ersatz promises like { [PASS_STYLE]: 'promise' }
, allowing convertValToSlot
and convertSlotToVal
functions to utilize such objects in place of native promises. How much state they should be allowed to carry is an open question, but my initial inclination is to either prohibit it entirely or to have it match what can be carried by a native promise (e.g., the { status: 'fulfilled', value: any } | { status: 'rejected', reason: any }
objects from Promise.allSettled
.
Issue Analytics
- State:
- Created a year ago
- Comments:15 (15 by maintainers)
Top GitHub Comments
I think that’s a feature, not a bug. I don’t think we want anyone to try to use one of these ersatz promises as an actual promise. The whole point is to be able to roundtrip from unserialization to serialization without the intermediate entity being usable as anything other than a (mostly) opaque token.
Requirement: E and E.when must work on these somehow.