-
-
Notifications
You must be signed in to change notification settings - Fork 801
Description
SessionStart hook crashes with SocketError: other side closed
Problem Statement
The Claude-mem plugin's context hook is experiencing fatal crashes during session initialization, causing the SessionStart:compact hook to fail with a socket connection error. This appears to be related to the worker service connection being unexpectedly closed during communication.
Environment
- Claude-mem: 8.5.4
- Claude Code: 2.0.76 (Claude Code)
- Node.js: v24.3.0
- Bun: 1.3.4
- OS: macOS 26.0 (arm64)
- Platform: darwin
- Worker Status: Running (PID: 17290, Port: 37777)
- Worker Uptime: 0 minutes
- Active Sessions: 3
- SSE Clients: 0
Steps to Reproduce
- Start a new chat session with Claude Code
- The session initialization triggers the
SessionStart:compacthook - The hook attempts to communicate with the worker service on port 37777
- Connection is established but then unexpectedly closed by the worker service
Expected Behavior
The SessionStart:compact hook should successfully communicate with the worker service and complete session initialization without errors.
Actual Behavior
The hook crashes with a SocketError: other side closed error, indicating the worker service closed the connection prematurely during the HTTP request/response cycle.
Error Logs
Error.captureStackTrace(err);
^
SocketError: other side closed
at Socket.onHttpSocketEnd (node:internal/deps/undici/undici:6965:26)
at Socket.emit (node:events:519:35)
at endReadableNT (node:internal/streams/readable:1701:12)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
code: 'UND_ERR_SOCKET',
socket: {
localAddress: '127.0.0.1',
localPort: 51146,
remoteAddress: '127.0.0.1',
remotePort: 37777,
remoteFamily: 'IPv4',
timeout: undefined,
bytesWritten: 2583,
bytesRead: 4058
}
}Location: file:///Users/beamnawapat/.claude/plugins/cache/thedotmack/claude-mem/8.5.4/scripts/context-hook.js:19:1773
Relevant Diagnostics
Silent Debug Log Patterns
The debug logs show recurring HAPPY-PATH-ERROR entries for:
Missing last_assistant_message in session for summary prompt(multiple occurrences)Missing last_user_message when queueing summary in SessionRoutes(multiple occurrences)
These errors suggest potential issues with session state management that may be related to the socket closure problem.
Worker Service Status
- Worker is running but shows 0 minutes uptime despite having 3 active sessions
- This could indicate recent restart or unstable worker process
Additional Context
The error occurs in the undici HTTP client library used by Node.js, suggesting the worker service may be:
- Crashing or restarting during request handling
- Timing out connections prematurely
- Incorrectly handling keep-alive or connection pooling
- Experiencing resource exhaustion with multiple concurrent sessions
The consistent pattern of missing message data in the debug logs may indicate a deeper issue with how session summaries are being generated and stored.