diff --git a/packages/core/src/actor/dispatch.ts b/packages/core/src/actor/dispatch.ts index e9168fd..3866515 100644 --- a/packages/core/src/actor/dispatch.ts +++ b/packages/core/src/actor/dispatch.ts @@ -14,10 +14,11 @@ export async function dispatch>; if (waitTillResponse) { returnValue = new Promise((resolve) => { - actor.onMessage((msgs) => { + const unsub = actor.onMessage((msgs) => { // TODO: just a workaround const msg = msgs[0] as unknown as Message; resolve(msg); + unsub(); }); }); }