Skip to content

Wrap async exit handler in try/catch to prevent potential hang #52

@mgoldsborough

Description

@mgoldsborough

Context

From QA review of issue-37-cli-add-bundle-update-awareness branch.

Problem

In packages/cli/src/commands/packages/run.ts, the child.on("exit", async (code) => { ... }) handler awaits the update check promise before calling process.exit(). If the await Promise.race rejects unexpectedly, process.exit never fires and the process hangs. The 3-second timeout mitigates this, but a try/catch would be defensive.

Suggested Fix

child.on("exit", async (code) => {
  if (updateCheckPromise) {
    try {
      await Promise.race([updateCheckPromise, new Promise((r) => setTimeout(r, 3000))]);
    } catch {}
  }
  process.exit(code ?? 0);
});

Severity

Warning — low probability but easy fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions