OpenCode crashes immediately on ingesting the following error #8728

Open
opened 2026-02-16 18:10:40 -05:00 by yindo · 1 comment
Owner

Originally created by @jillesme on GitHub (Feb 6, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Sorry for the clickbait title but it's the only way I can describe it. I was working on something with Cloudflare Workers AI and it outputted:

<anonymous_script>:1
�
^

SyntaxError: Unexpected token '', ""... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/infra/index.js:164:15)
    at successSteps (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/body.js:463:23)
    at readAllBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/util.js:998:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)

Node.js v25.3.0
 ELIFECYCLE  Command failed with exit code 1.

It kept crashing my opencode. I tried putting it in a gist, then paste it in a fresh session and it immediatley crashes.

Plugins

No response

OpenCode version

1.1.42

Steps to reproduce

  1. run opencode
  2. paste the following
<anonymous_script>:1
�
^

SyntaxError: Unexpected token '', ""... is not valid JSON
    at JSON.parse (<anonymous>)
    at parseJSONFromBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/infra/index.js:164:15)
    at successSteps (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/body.js:463:23)
    at readAllBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/util.js:998:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)

Node.js v25.3.0
 ELIFECYCLE  Command failed with exit code 1.

Screenshot and/or share link

No response

Operating System

MacOS

Terminal

Ghostty

Originally created by @jillesme on GitHub (Feb 6, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description Sorry for the clickbait title but it's the only way I can describe it. I was working on something with Cloudflare Workers AI and it outputted: ``` <anonymous_script>:1 � ^ SyntaxError: Unexpected token '', ""... is not valid JSON at JSON.parse (<anonymous>) at parseJSONFromBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/infra/index.js:164:15) at successSteps (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/body.js:463:23) at readAllBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/util.js:998:9) at process.processTicksAndRejections (node:internal/process/task_queues:103:5) Node.js v25.3.0  ELIFECYCLE  Command failed with exit code 1. ``` It kept crashing my opencode. I tried putting it in a gist, then paste it in a fresh session and it immediatley crashes. ### Plugins _No response_ ### OpenCode version 1.1.42 ### Steps to reproduce 1. run opencode 2. paste the following 3. ``` <anonymous_script>:1 � ^ SyntaxError: Unexpected token '', ""... is not valid JSON at JSON.parse (<anonymous>) at parseJSONFromBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/infra/index.js:164:15) at successSteps (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/body.js:463:23) at readAllBytes (/Users/jilles/Code/realtime-story/node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/web/fetch/util.js:998:9) at process.processTicksAndRejections (node:internal/process/task_queues:103:5) Node.js v25.3.0  ELIFECYCLE  Command failed with exit code 1. ``` ### Screenshot and/or share link _No response_ ### Operating System MacOS ### Terminal Ghostty
yindo added the bug label 2026-02-16 18:10:40 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 6, 2026):

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

  • #10783: OpenCode crashes with garbled tokens - appears to be a crash caused by malformed/binary data in input
  • #11698: Unprotected JSON.parse in provider fetch wrapper that can crash on malformed data
  • #7946: Crash on JSON parse errors from responses
  • #7123: Error processing when invalid/malformed error stacks are pasted

These all relate to OpenCode crashing when encountering malformed, binary, or non-UTF8 data. Your issue specifically shows binary characters (^_) that cause JSON parse failures. The root cause appears to be insufficient input validation/error handling when processing error messages or pasted content.

Feel free to ignore if your case is distinct from these.

@github-actions[bot] commented on GitHub (Feb 6, 2026): This issue might be a duplicate of existing issues. Please check: - #10783: OpenCode crashes with garbled tokens - appears to be a crash caused by malformed/binary data in input - #11698: Unprotected JSON.parse in provider fetch wrapper that can crash on malformed data - #7946: Crash on JSON parse errors from responses - #7123: Error processing when invalid/malformed error stacks are pasted These all relate to OpenCode crashing when encountering malformed, binary, or non-UTF8 data. Your issue specifically shows binary characters (`^_`) that cause JSON parse failures. The root cause appears to be insufficient input validation/error handling when processing error messages or pasted content. Feel free to ignore if your case is distinct from these.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8728