feat(swingset): allow buildRootObject to return a Promise #5250
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New (or upgraded) vats are defined by a user-provided
buildRootObject
function. This function has two responsibilities:defineDurableKind
to bind behavior to any pre-existing durablekinds
Previously,
buildRootObject
was given exactly one "turn" to fulfillthese responsibilities: it was required to return the root object
synchronously. If it returned a Promise, that was rejected as an
error.
This requirement is at odds with the needs for updated ZCF vats to
evaluate their contract code and interact with it (giving the contract
a chance to bind their own Kind behavior). The
importBundle
functionwe use to load contracts is async. However, it is still "prompt": it
needs no IO, nor any messages leaving the vat. So it will still
complete within the crank, just not synchronously within the turn.
So this commit changes liveslots to allow
buildRootObject
to returna Promise for the root object. The requirement, however, is that this
Promise must resolve by the end of the initial crank (before
waitUntilQuiescent
/setImmediate
determines that the promisequeue is empty). If the Promise is not fulfilled by then, the vat
creation/update is considered broken.
closes #5246