Skip to content

cc session transcripts are written incompletely: 1 line vs node's 5 (async queue-and-flush path, NOT the exit hooks) #9421

Description

@proggeramlug

claude --bare -p hi writes 1 line to ~/.claude/projects/<key>/<uuid>.jsonl where node writes 5. At scale: -p with 1 MB of stdin → node 2,409,463 B, perry 1,195,651 B. So --resume/--continue have little to resume.

This is NOT #9403

I originally filed it as a suspected consequence of process.on("exit") never firing. That premise is wrong, and here is the disproof: snapshotting the transcript from a prependListener("exit", …) under node shows all five records are already on disk before the first exit listener runs. Exit hooks are not involved.

Where the divergence actually is

The four records perry misses go through the session writer's async insertQueueOperation → flush path (Ng1 / x_() in the bundle). The one record perry does write — last-prompt — is a direct appendFileSync.

So the failing shape is: work enqueued asynchronously and flushed before exit is lost. Sync writes land. That is an async-flush / drain divergence, independent of the exit-event machinery fixed in #9420.

Suggested starting point

Compare, under both engines, when the queued flush actually runs relative to loop drain — a promise/microtask scheduling difference, an unawaited write, or a drain that exits before the queue empties would all produce exactly this. Note #9412 (nextTick demoted below promise microtasks after any builtin require) is a live scheduling divergence in the same neighbourhood and may be the mechanism.

Found by a differential stress-test of claude-code under perry; disproof of the #9403 premise came from #9420's verification work.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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