nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] Daemon crashes when an IPC client sends the JSON value null

Open addyCooks opened this issue 2 weeks ago • 1 comments

Description

A client that sends the line null to the daemon's IPC socket makes the daemon throw an uncaught exception and exit.

Environment

  • OS: Windows 11 Home 10.0.26300
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at f92cce9c)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. Start a server: const server = new DaemonIpcServer(path, {listSubscriptions: () => []}); await server.start();
  2. Add process.on('uncaughtException', ...) in the same script.
  3. Connect with net.createConnection(path) and write null\n.

Expected Behavior

The server replies with an error (or ignores the line) and keeps running.

Actual Behavior

The process gets an uncaught exception. Without a handler the daemon exits.

Logs/Screenshots

UNCAUGHT EXCEPTION: Cannot read properties of null (reading 'id')

Additional Context

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

Suggested fix:

  • source/daemon/ipc.ts around lines 119-131: after JSON.parse, check that the value is a non-null object with the expected fields.
  • source/daemon/ipc.ts:164-165: the catch block calls this.respond(socket, req.id, ...) and reads req.id again. Guard it (req?.id) so a bad request cannot throw from the error handler.
  • Add a test that sends null, a number and a string and checks the server stays up.

addyCooks avatar Nov 14 '26 06:11 addyCooks

I will pick this up. I will validate parsed IPC requests before dispatch, return an error for null/primitives/arrays or malformed fields, and test that a valid ping still works after malformed requests on the same connection.

Purv-Kabaria avatar Nov 14 '26 10:11 Purv-Kabaria