Skip to content

Copilot cli needs to be more resilient to crashes/unexpected shutdown and recover from them better. #2217

@AdamGlassStudio

Description

@AdamGlassStudio

Describe the bug

Title: Session fails to load after crash — trailing null bytes in events.jsonl not handled

Environment:

  • Copilot CLI v1.0.10
  • WSL2 (Linux
    5.15.167.4-microsoft-standard-WSL2)
  • Ubuntu / x86_64

Description:

After a crash (or abnormal termination), copilot --resume= reports "No session or task matched" even
though the session directory and all files exist on disk.

Root cause:

events.jsonl had 1,728 trailing null bytes (\x00) appended after the last valid JSON line. This is consistent with
buffered I/O where the file was extended but the process terminated before flushing real data. The session loader
fails to parse the file and treats the session as nonexistent.

Reproduction:

  1. Have an active Copilot CLI session with some conversation history
  2. Crash or force-kill the Copilot process (e.g., WSL shutdown, OOM, kill -9)
  3. Attempt copilot --resume=
  4. Result: "No session or task matched ''"

Workaround:

Manually strip the trailing nulls:

path = '~/.copilot/session-state//events.jsonl'
with open(path, 'rb') as f:
data = f.read()
with open(path, 'wb') as f:
f.write(data.rstrip(b'\x00'))

Suggested fix:

The session loader should be resilient to crash artifacts in events.jsonl:

  1. Strip trailing null bytes before parsing
  2. Skip/ignore blank or unparseable trailing lines (the last event may be incomplete)
  3. Log a warning that the session was recovered from a crash, noting how many events (if any) were lost

The 3,015 valid JSON lines in the file were completely intact — only the unwritten tail was corrupted. Refusing to
load the entire session over this is unnecessarily destructive.

Affected version

GitHub Copilot CLI 1.0.10

Steps to reproduce the behavior

No response

Expected behavior

tolerant of crashes, resumes or detects a problem and offers a better resolution

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions