Skip to content

Plugin syntax errors are handled poorly #4850

Closed

Description

@CodeReclaimers

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

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 28, 2025
  2. CodeReclaimers commented on Nov 28, 2025

    @CodeReclaimers
    Author

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

  3. github-actions commented on Nov 28, 2025

    @github-actions
    Contributor

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

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

  4. CodeReclaimers commented on Nov 28, 2025

    @CodeReclaimers
    Author

    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.

  5. CodeReclaimers commented on Nov 28, 2025

    @CodeReclaimers
    Author

    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
  6. removed
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Nov 28, 2025
  7. self-assigned this
    on Nov 28, 2025
  8. rekram1-node commented on Nov 28, 2025

    @rekram1-node
    Contributor

    ill check it out

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions