Skip to content

[Bug]: file:// plugin dedup silently drops plugins when multiple share the same filename (e.g. index.js) #14304

Closed as not planned

Description

@Aegis-commits

Description

When two or more plugins are loaded via file:// paths and their JS filenames are identical (e.g. both named index.js), deduplicatePlugins() silently drops all but one. No error or warning is logged.

Reproduction

// opencode.json
{
  "plugin": [
    "file:///home/user/plugin-a/dist/index.js",
    "file:///home/user/plugin-b/dist/index.js"
  ]
}

Expected: Both plugins load.
Actual: Only one loads (the later entry wins). The other is silently discarded.

Root Cause

getPluginName() extracts just the bare filename (without extension) for file:// URLs. Both paths resolve to canonical name "index". deduplicatePlugins() then treats them as the same plugin and keeps only the last one (reverse-order processing, last = highest priority).

Impact

This is a silent failure — no error, no warning, no log entry. The dropped plugin simply doesn't exist at runtime. This is especially likely during local plugin development where dist/index.js is the standard build output for most bundlers (bun, esbuild, rollup, etc.).

Suggested Fix

For file:// URLs, derive the canonical name from a more unique portion of the path rather than just the bare filename. Options:

  1. Use the parent directory name + filename (e.g. plugin-a/index → "plugin-a")
  2. Use the full path as the canonical name for file:// entries
  3. At minimum, log a warning when dedup discards a file:// plugin

Workaround

Ensure each file:// plugin has a unique JS filename:

ln -sf /path/to/plugin/dist/index.js /path/to/plugin/dist/my-plugin.js
{
  "plugin": [
    "file:///home/user/plugin-a/dist/plugin-a.js",
    "file:///home/user/plugin-b/dist/index.js"
  ]
}

Environment

  • OpenCode (latest)
  • Linux x86_64
  • Multiple file:// plugins in config

Activity

  1. github-actions commented on Feb 19, 2026

    @github-actions
    Contributor

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

    Please review these issues before continuing, and consider adding your findings there if they match your case.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 19, 2026
  3. cyberprophet commented on Mar 4, 2026

    @cyberprophet
    Contributor

    This is addressed by #15598 which adds node_modules-aware path parsing to getPluginName(). CI is green.

    The root cause is that import.meta.resolve resolves npm plugins to file://…/node_modules/<pkg>/dist/index.js, and then getPluginName() extracts only the filename "index", causing false collisions with any project plugin that also has an index.ts entry point.

    Related issues: #8759, #10115, #11159, #12285, #14304, #15591

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions