nanocoder
nanocoder copied to clipboard
[Bug] Daemon crashes when an IPC client sends the JSON value null
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
- Start a server:
const server = new DaemonIpcServer(path, {listSubscriptions: () => []}); await server.start(); - Add
process.on('uncaughtException', ...)in the same script. - Connect with
net.createConnection(path)and writenull\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.tsaround lines 119-131: afterJSON.parse, check that the value is a non-null object with the expected fields.source/daemon/ipc.ts:164-165: the catch block callsthis.respond(socket, req.id, ...)and readsreq.idagain. 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.
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.