Skip to content

refactor: rename reserved 'error' event to 'parseError' in StructuredOutputParser #52

@Cheezeiii365

Description

@Cheezeiii365

Context

StructuredOutputParser (packages/main/src/structuredOutputParser.ts) extends Node's EventEmitter and emits the reserved error event on JSON parse failures (line 44). Node's EventEmitter has special behavior: emit('error', ...) with zero listeners throws the error as an uncaught exception, crashing the process.

Current state

The sole consumer (cliAgentManager.ts:223-230) always attaches an error listener immediately after construction, before any data flows — so there is no crash risk today.

Recommended fix

Rename the error event to parseError (or add a default no-op listener in the constructor) to prevent future callers from accidentally crashing the main process by forgetting to attach a listener.

Files to update

  • packages/main/src/structuredOutputParser.ts — rename event in StructuredOutputParserEvents interface and emit() call
  • packages/main/src/cliAgentManager.ts — update parser.on('error', ...) to parser.on('parseError', ...)

Priority

Low — defensive hardening, not a current bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions