Summary
Enhance socket communication reliability with minor protocol improvements from CodeRabbit review.
Tasks
1. Strip carriage returns in argument sanitization
Location: src/hardware/socketClient.ts:47
Priority: Low
Currently only strips \n but leaves \r. If hardware daemon interprets \r as line ending, injected \r could confuse protocol.
Fix: Replace /\n/g with /[\r\n]/g in cleanArg sanitization.
2. Propagate socket errors to prevent hanging reads
Location: src/hardware/socketClient.ts:23-25
Priority: Low
Socket error handler only logs but doesn't propagate error state. In-flight readMessage() calls won't know socket is unhealthy until 30s timeout.
Fix:
- Set internal error flag when socket error occurs
- Forward error to MessageStream via
this.messageStream.destroy(error)
3. Make command delay configurable
Location: src/hardware/socketClient.ts:55-56
Priority: Low
Hardcoded 10ms delay adds latency to every command. Should be configurable or removed if not needed.
Fix:
- Add
commandDelayMs option to SocketClient constructor (default 0)
- Replace literal 10 with the option value
- Update connectToSocket() to pass option
Source: CodeRabbit PR #100 review
Summary
Enhance socket communication reliability with minor protocol improvements from CodeRabbit review.
Tasks
1. Strip carriage returns in argument sanitization
Location:
src/hardware/socketClient.ts:47Priority: Low
Currently only strips
\nbut leaves\r. If hardware daemon interprets\ras line ending, injected\rcould confuse protocol.Fix: Replace
/\n/gwith/[\r\n]/gin cleanArg sanitization.2. Propagate socket errors to prevent hanging reads
Location:
src/hardware/socketClient.ts:23-25Priority: Low
Socket error handler only logs but doesn't propagate error state. In-flight
readMessage()calls won't know socket is unhealthy until 30s timeout.Fix:
this.messageStream.destroy(error)3. Make command delay configurable
Location:
src/hardware/socketClient.ts:55-56Priority: Low
Hardcoded 10ms delay adds latency to every command. Should be configurable or removed if not needed.
Fix:
commandDelayMsoption to SocketClient constructor (default 0)Source: CodeRabbit PR #100 review