Skip to content

[Bug] DaemonIpcClient.request leaks memory and hangs if socket.write throws synchronously #1040

Description

@akramcodez

Description

When communicating with the background daemon over IPC, DaemonIpcClient.request adds the request promise to a pending map and then calls socket.write(). If the socket is already closed or in an error state, write() throws synchronously. Because there is no try/catch, the promise is never resolved/rejected and the slot leaks in the map forever.

Environment

  • OS: Any
  • Node version: Node 18+
  • Nanocoder version: 1.30.0

Steps to Reproduce

  1. Force a daemon crash or close the IPC socket prematurely.
  2. Attempt an IPC request right as the socket closes.
  3. write() throws, and the pending promise sits in memory forever.

Expected Behavior

If write() fails synchronously, the promise should be rejected and removed from the pending map.

Actual Behavior

The throw bypasses the promise resolution, leaking the map entry.

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

Implementation Notes

Wrap this.socket?.write() in a try/catch in source/daemon/ipc.ts:248-251. In the catch block, call reject(error) and this.pending.delete(id).

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo