Skip to content

Commit

Permalink
fix(daemon): Wait for mail delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Apr 13, 2024
1 parent 94b8ac3 commit 493f6bb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/daemon/src/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const makeMailboxMaker = ({ provide }) => {
/**
* @param {import('./types.js').EnvelopedMessage} envelope
*/
const deliver = async envelope => {
const deliver = envelope => {
/** @type {import('@endo/promise-kit/src/types.js').PromiseKit<void>} */
const dismissal = makePromiseKit();
const messageNumber = nextMessageNumber;
Expand Down Expand Up @@ -119,13 +119,13 @@ export const makeMailboxMaker = ({ provide }) => {
* @param {import('./types.js').Handle} recipient
* @param {import('./types.js').EnvelopedMessage} message
*/
const post = (recipient, message) => {
const post = async (recipient, message) => {
/** @param {object} allegedRecipient */
const envelope = makeEnvelope();
outbox.set(envelope, message);
E.sendOnly(recipient).receive(envelope, selfId);
await E(recipient).receive(envelope, selfId);
// Send to own inbox.
if (message.from !== message.to) {
// echo to own mailbox
deliver(message);
}
};
Expand Down Expand Up @@ -212,7 +212,7 @@ export const makeMailboxMaker = ({ provide }) => {
});

// add to recipient mailbox
post(to, message);
await post(to, message);
};

/** @type {import('./types.js').Mail['dismiss']} */
Expand Down Expand Up @@ -290,7 +290,7 @@ export const makeMailboxMaker = ({ provide }) => {
);

// Note: consider sending to each mailbox with different powers.
post(to, req);
await post(to, req);

const responseId = await responseIdP;
const responseP = provide(responseId);
Expand Down

0 comments on commit 493f6bb

Please sign in to comment.