diff --git a/packages/loot-core/src/platform/client/connection/index.ts b/packages/loot-core/src/platform/client/connection/index.ts index e1610d11be..1c3d6ee867 100644 --- a/packages/loot-core/src/platform/client/connection/index.ts +++ b/packages/loot-core/src/platform/client/connection/index.ts @@ -50,7 +50,7 @@ function handleMessage(msg) { handler.reject(error); } } else if (msg.type === 'reply') { - const { id, result, mutated, undoTag } = msg; + const { id, result, mutated, undoTag, error } = msg; const handler = replyHandlers.get(id); if (handler) { @@ -60,7 +60,13 @@ function handleMessage(msg) { undo.gc(undoTag); } - handler.resolve(result); + // api/* handler failures arrive as a reply carrying `error` (see + // platform/server/connection); reject rather than resolving undefined. + if (error) { + handler.reject(error); + } else { + handler.resolve(result); + } } } else if (msg.type === 'push') { const { name, args } = msg;