Skip to content

Exceptions lead to invalid session JSONL. #368

@ysazhm0109-boop

Description

@ysazhm0109-boop

claude-sdk.js 576

for await (const message of queryInstance) {
...
ws.send({
type: 'claude-response',
data: transformedMessage,
sessionId: capturedSessionId || sessionId || null
});
....
}

If an exception occurs inside the for await (const message of queryInstance) loop—for example, when the WebSocket disconnects (user closes the page right after starting the conversation)—ws.send throws an error and breaks the JSONL write. You're left with only the partial entry {"type":"queue-operation","operation":"dequeue",...}. When the session restarts, the Claude Code SDK generates a new sessionId, so the old and new IDs don't match anymore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions