Skip to content

[Bug] custom-tools/handler.ts double-kill timer leak #1141

Description

@akramcodez

Description

After child.kill('SIGTERM'), an unref'd setTimeout(... 1000) schedules child.kill('SIGKILL'). If the child exited cleanly within 1s, the timer still fires and calls kill on a dead process (the !child.killed guard doesn't reliably catch it).

Environment

  • OS: Any
  • Node version: v22.20.0
  • Nanocoder version: 1.30.0
  • Provider: N/A
  • Model: N/A

Steps to Reproduce

  1. Run a custom tool that terminates immediately upon receiving SIGTERM.
  2. Wait 1 second and monitor process logs.

Expected Behavior

The SIGKILL timer should be cleared when the process exits.

Actual Behavior

The timer fires, attempting to kill a dead process, potentially causing an unhandled error or noisy warning.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder

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

    area:toolsTool implementations and tool-callingbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions