MAESTRO: Address PR review feedback — fix connection lifecycle, lazy channel access, buffer safety

- Move sseAbortController/connectionState from module globals into closure for multi-instance safety
- Make start() idempotent by aborting existing connection before creating a new one
- Track connectionPromise and await it on stop() for proper cleanup
- Guard channel API access lazily to prevent crash when integrations are missing
- Add 1MB MAX_SSE_BUFFER_SIZE to prevent unbounded buffer growth
- Log malformed JSON parse errors instead of silently ignoring
- Replace error: any with proper instanceof Error type narrowing
- Remove hardcoded user paths from TESTING.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Newman
2026-02-07 20:06:29 -05:00
parent f1ecf5bc68
commit db207807cb
2 changed files with 65 additions and 36 deletions
+3 -3
View File
@@ -28,7 +28,7 @@ curl -s -N http://localhost:37777/stream --max-time 3 2>/dev/null || true
**If the worker is not running:**
```bash
cd /Users/alexnewman/Scripts/claude-mem
cd /path/to/claude-mem
npm run build-and-sync
```
@@ -50,7 +50,7 @@ cat ~/.openclaw/openclaw.json
{
"claude-mem": {
"enabled": true,
"source": "/Users/alexnewman/Scripts/claude-mem/openclaw",
"source": "/path/to/claude-mem/openclaw",
"config": {
"syncMemoryFile": true,
"workerPort": 37777,
@@ -135,7 +135,7 @@ node test-sse-consumer.js
### Worker not running
- **Symptom:** Gateway logs show `SSE stream error: fetch failed. Reconnecting in 1s`
- **Fix:** Start the worker with `cd /Users/alexnewman/Scripts/claude-mem && npm run build-and-sync`
- **Fix:** Start the worker with `cd /path/to/claude-mem && npm run build-and-sync`
### Port mismatch
- **Symptom:** SSE connection fails even though worker health check passes