Skip to content

fix(plugin): reject bootstrap client reentry#31859

Open
ualtinok wants to merge 1 commit into
anomalyco:devfrom
ualtinok:shared-server-runtime
Open

fix(plugin): reject bootstrap client reentry#31859
ualtinok wants to merge 1 commit into
anomalyco:devfrom
ualtinok:shared-server-runtime

Conversation

@ualtinok

@ualtinok ualtinok commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #31858

Type of change

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

What does this PR do?

This PR has been narrowed after upstream landed 87c33b3d85a6c874e7b5af6af8fd6784e0e1bfbd (fix(plugin): reuse active server for client requests).

That upstream commit fixes the main runtime split for normal post-init plugin SDK calls: when opencode serve or Desktop has an active listener, plugin input.client now targets the active listener instead of the default in-process Server.Default() runtime. That prevents the duplicate plugin load / duplicate promptAsync runner split for the common live-server path.

I verified that narrower upstream fix against the Docker repro: bare opencode-ai@1.17.7 no longer reproduces the main issue (plugin_init count: 1, and the promptAsync marker has one assistant child with one stop).

What remains unsolved is bootstrap re-entry. If a plugin calls input.client.* while its server(input) / config hooks are still loading, the active listener can route the request back into the same instance load. The instance is already booting and its deferred is not resolved yet, so the request can wait on the plugin load that is itself waiting on the request.

This PR now focuses only on that remaining path:

  • While a plugin instance is still bootstrapping, plugin client requests return 409 Conflict instead of re-entering the same instance load.
  • After bootstrapping completes, plugin client requests continue to use upstream's existing Server.url active-listener bridge unchanged.
  • The previous broader runtime replacement has been removed from this PR.

How did you verify your code works?

  • Verified the main repro against bare opencode-ai@1.17.7: not reproduced (plugin_init count: 1; promptAsync marker had one assistant child / one stop).
  • Added focused regression coverage for plugin client re-entry during plugin loading.
  • Ran git diff --check and source diagnostics for the narrowed patch.

Screenshots / recordings

N/A

Checklist

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

@code-yeongyu

Copy link
Copy Markdown
Contributor

Yo guys please please i am begging

@dhaern

dhaern commented Jun 11, 2026

Copy link
Copy Markdown

Please

@BrianAguilarWasco

Copy link
Copy Markdown

add!

@ualtinok
ualtinok force-pushed the shared-server-runtime branch 2 times, most recently from b8937cd to cf38078 Compare June 16, 2026 14:57
@ualtinok ualtinok changed the title fix: share plugin client runtime fix(plugin): reject bootstrap client reentry Jun 16, 2026
randomvariable added a commit to randomvariable/opencode that referenced this pull request Jun 25, 2026
Guard the plugin HTTP client so requests issued from a plugin's server()
hook while the instance's plugins are still loading return a 409 instead of
re-entering the still-initializing instance and deadlocking. The guard is
cleared once plugin loading and config-notify hooks complete.

Ported from anomalyco#31859 (adapted onto this fork's createPluginClient transport).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable added a commit to randomvariable/opencode that referenced this pull request Jun 25, 2026
Guard the plugin HTTP client so requests issued from a plugin's server()
hook while the instance's plugins are still loading return a 409 instead of
re-entering the still-initializing instance and deadlocking. The guard is
cleared once plugin loading and config-notify hooks complete.

Ported from anomalyco#31859 (adapted onto this fork's createPluginClient transport).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
randomvariable added a commit to randomvariable/opencode that referenced this pull request Jun 30, 2026
Guard the plugin HTTP client so requests issued from a plugin's server()
hook while the instance's plugins are still loading return a 409 instead of
re-entering the still-initializing instance and deadlocking. The guard is
cleared once plugin loading and config-notify hooks complete.

Ported from anomalyco#31859 (adapted onto this fork's createPluginClient transport).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ualtinok
ualtinok force-pushed the shared-server-runtime branch from 49c7b0c to 0370eed Compare July 2, 2026 08:19
iceteaSA added a commit to iceteaSA/opencode that referenced this pull request Jul 2, 2026
# Conflicts:
#	packages/opencode/src/plugin/index.ts
iceteaSA added a commit to iceteaSA/opencode that referenced this pull request Jul 8, 2026
# Conflicts:
#	packages/opencode/src/plugin/index.ts
randomvariable added a commit to randomvariable/opencode that referenced this pull request Jul 10, 2026
Guard the plugin HTTP client so requests issued from a plugin's server()
hook while the instance's plugins are still loading return a 409 instead of
re-entering the still-initializing instance and deadlocking. The guard is
cleared once plugin loading and config-notify hooks complete.

Ported from anomalyco#31859 (adapted onto this fork's createPluginClient transport).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ualtinok
ualtinok force-pushed the shared-server-runtime branch from 2e129aa to 2cf22d6 Compare July 15, 2026 07:18
randomvariable added a commit to randomvariable/opencode that referenced this pull request Jul 17, 2026
Guard the plugin HTTP client so requests issued from a plugin's server()
hook while the instance's plugins are still loading return a 409 instead of
re-entering the still-initializing instance and deadlocking. The guard is
cleared once plugin loading and config-notify hooks complete.

Ported from anomalyco#31859 (adapted onto this fork's createPluginClient transport).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin client calls split from live listener runtime

4 participants