Crash when rerunning prompt with deleted file reference #6578

Closed
opened 2026-02-16 18:04:38 -05:00 by yindo · 2 comments
Owner

Originally created by @BNasraoui on GitHub (Jan 17, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

When using the @ command to reference a file, if you:

  1. Reference a file in a prompt
  2. Run the prompt
  3. Delete the file/folder
  4. Press up arrow to restore the previous prompt
  5. Press Enter to rerun

OpenCode throws an uncaught exception that blocks the chat window.

Root Cause

packages/opencode/src/session/prompt.ts:947 calls Bun.file(filepath).stat() without checking if the file exists first.

Expected Behavior

Should handle missing files gracefully with an error message rather than crashing.

Originally created by @BNasraoui on GitHub (Jan 17, 2026). Originally assigned to: @rekram1-node on GitHub. ## Description When using the @ command to reference a file, if you: 1. Reference a file in a prompt 2. Run the prompt 3. Delete the file/folder 4. Press up arrow to restore the previous prompt 5. Press Enter to rerun OpenCode throws an uncaught exception that blocks the chat window. ## Root Cause `packages/opencode/src/session/prompt.ts:947` calls `Bun.file(filepath).stat()` without checking if the file exists first. ## Expected Behavior Should handle missing files gracefully with an error message rather than crashing.
yindo closed this issue 2026-02-16 18:04:38 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 17, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #8807: Unhandled ENOENT error when submitting a message with a deleted file attachment (extremely similar - same root cause with Bun.file(filepath).stat() on deleted files)
  • #4522: Missing files when using @ to reference files mid sentence
  • #4011: bug: referencing file causes issue (using @ reference causes terminal crash)
  • #7773: Service crashes on missing session file (NotFoundError) - similar pattern of missing file handling

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 17, 2026): This issue might be a duplicate of existing issues. Please check: - #8807: Unhandled ENOENT error when submitting a message with a deleted file attachment (extremely similar - same root cause with `Bun.file(filepath).stat()` on deleted files) - #4522: Missing files when using @ to reference files mid sentence - #4011: bug: referencing file causes issue (using @ reference causes terminal crash) - #7773: Service crashes on missing session file (NotFoundError) - similar pattern of missing file handling Feel free to ignore if none of these address your specific case.
Author
Owner

@BNasraoui commented on GitHub (Jan 17, 2026):

Dupe of https://github.com/anomalyco/opencode/issues/8807

@BNasraoui commented on GitHub (Jan 17, 2026): Dupe of https://github.com/anomalyco/opencode/issues/8807
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6578