Skip to content

Commit

Permalink
fix: liveslots use the returned promise rather than our own
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Apr 11, 2020
1 parent 18e8dd1 commit 3135d9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions packages/SwingSet/src/kernel/liveSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function build(syscall, _state, makeRoot, forVatID) {
function makeQueued(slot) {
/* eslint-disable no-use-before-define */
const handler = {
applyMethod(_o, prop, args) {
applyMethod(_o, prop, args, returnedP) {
// Support: o~.[prop](...args) remote method invocation
return queueMessage(slot, prop, args);
return queueMessage(slot, prop, args, returnedP);
},
};
/* eslint-enable no-use-before-define */
Expand Down Expand Up @@ -233,7 +233,7 @@ function build(syscall, _state, makeRoot, forVatID) {

const m = makeMarshal(convertValToSlot, convertSlotToVal);

function queueMessage(targetSlot, prop, args) {
function queueMessage(targetSlot, prop, args, returnedP) {
const serArgs = m.serialize(harden(args));
const result = allocatePromiseID();
const done = makeQueued(result);
Expand All @@ -248,10 +248,10 @@ function build(syscall, _state, makeRoot, forVatID) {
lsdebug(`ls[${forVatID}].queueMessage.importedPromiseThen ${result}`);
importedPromiseThen(result);

// prepare the serializer to recognize it, if it's used as an argument or
// return value
valToSlot.set(done.p, result);
slotToVal.set(result, done.p);
// prepare the serializer to recognize the promise we will return,
// if it's used as an argument or return value
valToSlot.set(returnedP, result);
slotToVal.set(result, returnedP);

return done.p;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-vpid-liveslots.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ async function doVatResolveCase1(t, mode) {
async run(target1) {
const p1 = pr.promise;
E(target1).one(p1);
resolvePR(pr, mode);
// TODO: this stall shouldn't be necessary, but if I omit it, the
// fulfillToPresence happens *after* two() is sent
await Promise.resolve();
resolvePR(pr, mode);
E(target1).two(p1);
},
});
Expand Down

0 comments on commit 3135d9a

Please sign in to comment.