Plugin syntax errors are handled poorly #3174

Open
opened 2026-02-16 17:38:59 -05:00 by yindo · 5 comments
Owner

Originally created by @CodeReclaimers on GitHub (Nov 27, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

The Problem

Plugin syntax errors are handled poorly:

  • Errors only show in stdout as raw JSON (not in UI)
  • Error messages are unhelpful ("AggregateError: 2 errors" with no details)
  • No indication in the UI that a plugin failed to load
  • May crash with core dump in some cases

What Happened

While developing a plugin, a missing closing brace }; caused:

  1. First attempt: OpenCode crashed with segmentation fault (core dump)
  2. After restart: Same error now shows JSON to stdout, then OpenCode exits
  3. Result: Very difficult to debug - had to watch terminal output

The Syntax Error

File: session-logger-broken.ts
Line: 91
Error: Missing closing brace for object literal

const example = {
  // ... properties
}, // ← Missing semicolon and closing brace here

examples.push(example); // ← This causes syntax error

What Should Happen

Show error in the UI (toast notification or status bar)
Display the actual syntax error with line number
Show which plugin failed
List loaded/failed plugins somewhere visible
Never crash the main process

BUG_REPORT.md
session-logger-broken copy.ts.txt

OpenCode version

1.0.119

Steps to reproduce

  1. Create a plugin file .opencode/plugin/session-logger-broken.ts
  2. Copy the contents of the attached session-logger-broken copy.ts.txt file (contains syntax error - missing closing brace)
  3. Start OpenCode with opencode command
  4. Current Result: JSON error printed to stdout, OpenCode exits
  5. To see the error: Check stdout/terminal output for JSON error message
  6. Previous Result (in same terminal window but different tab): OpenCode would crash with segmentation fault

See my comment below with a script that reliably causes opencode to dump core.

session-logger-broken copy.ts.txt

Screenshot and/or share link

No TUI ever appeared, I got this on stdout instead and opencode terminated:

{
"name": "UnknownError",
"data": {
"message": "AggregateError: 2 errors building "/home/alan/opencode-dspy/.opencode/plugin/session-logger-broken.ts"\n at requestFetch (native:1:11)\n at (native:11:43)\n at (native:11:37)\n at requestInstantiate (native:1:11)\n at requestSatisfyUtil (native:1:11)\n at requestSatisfy (native:1:11)\n at requestImportModule (native:2)\n at requestImportModule (native:1:17)\n at (src/plugin/index.ts:42:32)\n at processTicksAndRejections (native:7:39)"
}
}

Operating System

Ubuntu 22.04

Terminal

kitty

Originally created by @CodeReclaimers on GitHub (Nov 27, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description ## The Problem Plugin syntax errors are handled poorly: - Errors only show in stdout as raw JSON (not in UI) - Error messages are unhelpful ("AggregateError: 2 errors" with no details) - No indication in the UI that a plugin failed to load - May crash with core dump in some cases ## What Happened While developing a plugin, a missing closing brace `};` caused: 1. **First attempt**: OpenCode crashed with segmentation fault (core dump) 2. **After restart**: Same error now shows JSON to stdout, then OpenCode exits 3. **Result**: Very difficult to debug - had to watch terminal output ## The Syntax Error File: `session-logger-broken.ts` Line: 91 Error: Missing closing brace for object literal ```typescript const example = { // ... properties }, // ← Missing semicolon and closing brace here examples.push(example); // ← This causes syntax error ``` ## What Should Happen ✅ Show error in the UI (toast notification or status bar) ✅ Display the actual syntax error with line number ✅ Show which plugin failed ✅ List loaded/failed plugins somewhere visible ✅ Never crash the main process [BUG_REPORT.md](https://github.com/user-attachments/files/23813158/BUG_REPORT.md) [session-logger-broken copy.ts.txt](https://github.com/user-attachments/files/23813254/session-logger-broken.copy.ts.txt) ### OpenCode version 1.0.119 ### Steps to reproduce 1. Create a plugin file `.opencode/plugin/session-logger-broken.ts` 2. Copy the contents of the attached `session-logger-broken copy.ts.txt` file (contains syntax error - missing closing brace) 3. Start OpenCode with `opencode` command 4. **Current Result**: JSON error printed to stdout, OpenCode exits 5. **To see the error**: Check stdout/terminal output for JSON error message 6. **Previous Result (in same terminal window but different tab)**: OpenCode would crash with segmentation fault See my comment below with a [script](https://github.com/user-attachments/files/23813456/session-logger-severely-broken.ts.txt) that reliably causes opencode to dump core. [session-logger-broken copy.ts.txt](https://github.com/user-attachments/files/23813209/session-logger-broken.copy.ts.txt) ### Screenshot and/or share link No TUI ever appeared, I got this on stdout instead and opencode terminated: { "name": "UnknownError", "data": { "message": "AggregateError: 2 errors building \"/home/alan/opencode-dspy/.opencode/plugin/session-logger-broken.ts\"\n at requestFetch (native:1:11)\n at <anonymous> (native:11:43)\n at <anonymous> (native:11:37)\n at requestInstantiate (native:1:11)\n at requestSatisfyUtil (native:1:11)\n at requestSatisfy (native:1:11)\n at requestImportModule (native:2)\n at requestImportModule (native:1:17)\n at <anonymous> (src/plugin/index.ts:42:32)\n at processTicksAndRejections (native:7:39)" } } ### Operating System Ubuntu 22.04 ### Terminal kitty
yindo added the bug label 2026-02-16 17:38:59 -05:00
Author
Owner

@CodeReclaimers commented on GitHub (Nov 27, 2025):

(with props to opencode for writing its own bug report)

@CodeReclaimers commented on GitHub (Nov 27, 2025): (with props to opencode for writing its own bug report)
Author
Owner

@github-actions[bot] commented on GitHub (Nov 27, 2025):

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

  • #3392: Plugin loading errors causing crashes on startup (scoped npm packages) - shows similar pattern of config corruption and crashes
  • #3537: Plugin/config file parsing crashes OpenCode on startup - similar pattern of crashes with poor error messages
  • #4650: Flash crash on startup with empty JSON output to stdout - very similar symptom of exiting with unhelpful JSON
  • #4145: Crashes on bad config without helpful feedback - general lack of error handling improvements
  • #3568: Crashes immediately after startup with unhelpful error messages
  • #2455: General need for improved error handling and reporting across the app
  • #4846: Plugin loading/event subscription failures - related to plugin initialization issues

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

@github-actions[bot] commented on GitHub (Nov 27, 2025): This issue might be a duplicate of existing issues. Please check: - #3392: Plugin loading errors causing crashes on startup (scoped npm packages) - shows similar pattern of config corruption and crashes - #3537: Plugin/config file parsing crashes OpenCode on startup - similar pattern of crashes with poor error messages - #4650: Flash crash on startup with empty JSON output to stdout - very similar symptom of exiting with unhelpful JSON - #4145: Crashes on bad config without helpful feedback - general lack of error handling improvements - #3568: Crashes immediately after startup with unhelpful error messages - #2455: General need for improved error handling and reporting across the app - #4846: Plugin loading/event subscription failures - related to plugin initialization issues Feel free to ignore if none of these address your specific case.
Author
Owner

@CodeReclaimers commented on GitHub (Nov 27, 2025):

This is at least a partial duplicate, but the initial behavior of opencode when I first ran with this plugin was to dump core (and FUBAR my terminal tab) so it seems like there's something more going on sometimes than just an exit with a JSON message.

@CodeReclaimers commented on GitHub (Nov 27, 2025): This is at least a partial duplicate, but the initial behavior of opencode when I first ran with this plugin was to dump core (and FUBAR my terminal tab) so it seems like there's something more going on sometimes than just an exit with a JSON message.
Author
Owner

@CodeReclaimers commented on GitHub (Nov 27, 2025):

I can reliably get a core dump with this plugin script when starting opencode from the directory opencode-dspy. Removing the script results in a successful opencode launch.

session-logger-severely-broken.ts.txt

Image
@CodeReclaimers commented on GitHub (Nov 27, 2025): I can reliably get a core dump with this plugin script when starting opencode from the directory opencode-dspy. Removing the script results in a successful opencode launch. [session-logger-severely-broken.ts.txt](https://github.com/user-attachments/files/23813456/session-logger-severely-broken.ts.txt) <img width="394" height="119" alt="Image" src="https://github.com/user-attachments/assets/a3fbb384-6fd2-4bb0-ae38-b00df002a8cf" />
Author
Owner

@rekram1-node commented on GitHub (Nov 28, 2025):

ill check it out

@rekram1-node commented on GitHub (Nov 28, 2025): ill check it out
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3174