nanocoai/nanoclaw · info

ncl CLI server connection error

Error message

ncl CLI server connection error

What it means

A client connection to the ncl CLI Unix socket emitted an error event. This is a transport-level warning about a single connection (usually a client disconnecting abruptly), not a host failure; the server keeps running.

Source

Thrown at src/cli/socket-server.ts:68

  const s = server;
  server = null;
  await new Promise<void>((resolve) => s.close(() => resolve()));
}

function handleConnection(conn: net.Socket): void {
  let buffer = '';
  conn.on('data', (chunk) => {
    buffer += chunk.toString('utf8');
    let idx: number;
    while ((idx = buffer.indexOf('\n')) >= 0) {
      const line = buffer.slice(0, idx).trim();
      buffer = buffer.slice(idx + 1);
      if (!line) continue;
      void handleFrame(conn, line);
    }
  });
  conn.on('error', (err) => {
    log.warn('ncl CLI server connection error', { err });
  });
}

async function handleFrame(conn: net.Socket, line: string): Promise<void> {
  let req: RequestFrame;
  try {
    const parsed: unknown = JSON.parse(line);
    if (!isRequestFrame(parsed)) throw new Error('bad request shape');
    req = parsed;
  } catch (e) {
    write(conn, {
      id: 'unknown',
      ok: false,
      error: {
        code: 'transport-error',
        message: `bad frame: ${e instanceof Error ? e.message : String(e)}`,
      },
    });

View on GitHub (pinned to 294ef2aee8)

Solutions

  1. Usually ignorable if ncl commands otherwise succeed
  2. Correlate timestamps with aborted ncl invocations to confirm cause
  3. If persistent, inspect client-side errors (e.g. `ncl --json ...` output) for the real failure
Defensive patterns

Strategy: try-catch

Try / catch

conn.on('error', err => { /* log and ignore per-connection errors; server stays up */ });

Prevention

When it happens

Trigger: An `ncl` client process is killed mid-request, a malformed client connects and resets, or the socket is closed while a frame is still being written.

Common situations: Users Ctrl-C an ncl invocation, scripting timeouts that kill ncl, or health probes opening/closing the socket rapidly.

Related errors


AI-assisted analysis of nanocoai/nanoclaw@294ef2aee8 (2026-08-28). Data as JSON: /api/errors/8c6985c322e8e7e4. Report an issue: GitHub.