Skip to content

thread:send IPC handler always returns { ok: true } even when launch fails #57

Closed

Description

@Yash990-bit

Description

In apps/desktop/src/main/index.ts, the thread:send IPC handler attempts to catch early failures from runner.send() and return { ok: false, error } to the caller. However, because runner.send is an async function and is invoked unawaited (void runner.send(...)), initialization errors return a rejected Promise that bypasses the try...catch block.

As a result, thread:send unconditionally returns { ok: true }, and error handling in the renderer is never triggered.

Code reference

In apps/desktop/src/main/index.ts:

ipcMain.handle("thread:send", async (_e, { threadId, text }: { threadId: string; text: string }) => {
  try {
    void runner.send(threadId, text).catch((err) => {
      console.error(`thread:send uncaught in background for ${threadId}:`, err);
    });
    // Yield briefly so a synchronously-failing send surfaces an error to the caller.
    await new Promise((r) => setTimeout(r, 0));
    return { ok: true };
  } catch (err) {
    return { ok: false, error: err instanceof Error ? err.message : String(err) };
  }
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions