Skip to content

fix: add 30s timeout to plugin dynamic import to prevent silent deadlocks - #31464

Closed
7emotions wants to merge 1 commit into
anomalyco:devfrom
7emotions:fix/plugin-import-timeout
Closed

7emotions wants to merge 1 commit into
anomalyco:devfrom
7emotions:fix/plugin-import-timeout

Conversation

@7emotions

@7emotions 7emotions commented Jun 9, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #31463

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

PluginLoader.load() calls await import(row.entry) with no timeout. The broader deadlock is in Npm.add() → Arborist reify() (cold cache only), but adding a timeout to import() prevents silent hangs regardless of where the deadlock occurs. If the import times out, a clear error is surfaced instead of an invisible hang.

Root cause (confirmed via cache inspection)

The real deadlock is in Npm.add() — Arborist reify() hangs when the npm cache is cold. Once ~/.cache/opencode/packages/oh-my-openagent@latest/ is populated, the cache fast-path skips reify() and everything works. This is likely related to #23143 (no TTL on @latest re-reify).

How did you verify your code works

  • Built OpenCode from source with the change
  • Running the dev binary against oh-my-openagent@latest with a cold cache triggered Npm.add() → reify() successfully (populated the cache)
  • Original installed OpenCode 1.16.2 then also works against the same specifier (cache hit)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…ocks

When a npm package specifier (e.g. oh-my-openagent@latest) deadlocks
during import(), the process hangs indefinitely with no visible error.
Wrapping import() with Promise.race + setTimeout surfaces a clear error
message and allows other plugins to continue loading.

Related: anomalyco#23143 anomalyco#25668
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 9, 2026
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@7emotions 7emotions closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin import hangs silently when resolving npm specifiers (e.g. oh-my-openagent@latest)

1 participant