Skip to content

Harden spawn, signal handling, and null-error guards across run command and runtime hooks#18

Merged
naheel0 merged 2 commits intodatabasefrom
copilot/sub-pr-17
Mar 1, 2026
Merged

Harden spawn, signal handling, and null-error guards across run command and runtime hooks#18
naheel0 merged 2 commits intodatabasefrom
copilot/sub-pr-17

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

Several robustness gaps existed in the run command and the injector/auto/matcher modules: hard-coded "node" binary, missing signal-kill detection, no exit on spawn error, and unguarded property access on non-Error throws.

Changes

bin/index.js

  • Replace spawn("node", ...) with spawn(process.execPath, ...) so the CLI always uses the same Node binary that invoked it
  • Add explicit { stdio: ["inherit", "pipe", "pipe"] } — stdin is inherited, stdout/stderr are piped
  • close handler now accepts (code, signal); code === null is treated as a signal kill, logs the signal, and exits 1; otherwise uses process.exit(code ?? 1) as a safety net
  • child.on("error") now calls process.exit(1) after logging, preventing the CLI from hanging on spawn failures

lib/auto.js

  • Guard against non-Error throws: const msg = (err && err.message) ? err.message : String(err) passed to findError instead of bare err.message

lib/injector.js

  • Both uncaughtException and unhandledRejection handlers normalize the thrown value before accessing .stack/.message:
    const errStr = err !== null && typeof err === "object"
      ? (err.stack || err.message)
      : String(err ?? "unknown error");
    Prevents a secondary crash when null, a primitive, or a non-Error is thrown.

lib/matcher.js

  • Add if (typeof input !== "string") input = String(input) before input.toLowerCase() to handle non-string values passed to findError

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…rs, add type guard in matcher

Co-authored-by: jaseel0 <225665919+jaseel0@users.noreply.github.com>
Copilot AI changed the title [WIP] Add 'run' command, injector, and matcher updates Harden spawn, signal handling, and null-error guards across run command and runtime hooks Mar 1, 2026
@naheel0 naheel0 marked this pull request as ready for review March 1, 2026 13:49
@naheel0 naheel0 merged commit 5550209 into database Mar 1, 2026
1 check passed
@naheel0 naheel0 deleted the copilot/sub-pr-17 branch March 1, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants