openclaw - ✅(Solved) Fix [Bug]: WeChat plugin fails to start — api.runtime undefined in 2026.5.4 causes runtime initialization timeout [1 pull requests, 7 comments, 7 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#77779Fetched 2026-05-06 06:21:37
View on GitHub
Comments
7
Participants
7
Timeline
22
Reactions
2
Author
Timeline (top)
commented ×7subscribed ×5cross-referenced ×4mentioned ×3

After upgrading OpenClaw from 2026.3.x to 2026.5.4, the @tencent-weixin/openclaw-weixin plugin (v2.4.1) fails to start with Weixin runtime initialization timeout and enters an auto-restart crash loop (10 attempts). The root cause is that api.runtime is now undefined in the plugin register() callback, so setWeixinRuntime() is never called.

Error Message

[starting weixin provider (https://ilinkai.weixin.qq.com)] [waiting for Weixin runtime...] [waitForWeixinRuntime() failed: Error: Weixin runtime initialization timeout] [channel exited: Weixin runtime initialization timeout] [auto-restart attempt N/10 in Xs]

Root Cause

In the plugin entry point (index.js):

register(api) {
    assertHostCompatibility(api.runtime?.version);
    if (api.runtime) {                    // ← api.runtime is undefined in 2026.5.4
        setWeixinRuntime(api.runtime);    // ← never called
    }
    api.registerChannel({ plugin: weixinPlugin });
}

The monitor then calls waitForWeixinRuntime() which polls for the global pluginRuntime variable — but since setWeixinRuntime() was never called, it always times out after 10 seconds.

In 2026.3.x, api.runtime was populated during register(). In 2026.5.4, it appears to be undefined — likely a breaking change in the plugin SDK.

Fix Action

Fixed

PR fix notes

PR #77799: fix(plugins): forward setChannelRuntime from non-bundled external setup entries

Description (problem / solution / changelog)

Root cause

resolveSetupChannelRegistration in src/plugins/loader-channel-setup.ts handles two setup-entry export formats. The bundled-contract path ({kind:"bundled-channel-setup-entry", loadSetupPlugin, setChannelRuntime}) correctly extracted and returned setChannelRuntime. The non-bundled plain-object path ({plugin, setChannelRuntime}) only extracted plugin and silently dropped setChannelRuntime.

The consequence is specific to how setup-runtime mode works: registerChannel is always active in registry.ts (exposed unconditionally, not gated on capabilityHandlers), and with runtimeChannel=true in setup-runtime mode it writes the plugin into registry.channels immediately. The channel provider therefore starts during Phase 1 (before gateway listen), not Phase 2. Any runtime initializer the provider polls for must be satisfied via setChannelRuntime in the setup entry — it cannot wait for Phase 2's register() call.

Without this fix:

  1. Phase 1 loads the setup entry → setChannelRuntime is dropped → runtime initializer never called → pluginRuntime = null
  2. The channel is written into registry.channels in Phase 1 → provider starts immediately
  3. Provider polls for runtime, finds it null, times out → gateway crash loop
  4. Phase 2 eventually calls register() with a valid runtime but the channel has already exited

With this fix: setChannelRuntime(api.runtime) is invoked in Phase 1, the runtime is set before the provider starts, and the poll returns immediately.

What changed

  • src/plugins/loader-channel-setup.ts: extend the non-bundled return path to also extract setChannelRuntime when it is a function, mirroring the existing bundled-contract path.
  • src/plugins/loader.test.ts: regression test covering the exact failure path — configured channel with startupDeferConfiguredChannelFullLoadUntilAfterListen and preferSetupRuntimeForChannelPlugins: true, non-bundled setup entry exporting {plugin, setChannelRuntime}. Asserts both that the setter is invoked and that the channel lands in registry.channels in Phase 1, confirming the provider starts before Phase 2.
  • CHANGELOG.md: added entry under ## Unreleased.

What did NOT change

  • The bundled setup-entry path is unchanged.
  • loader.ts:2218 invocation site is unchanged.
  • No changes to the Phase 2 / reloadDeferredGatewayPlugins / register() flow.

Risk / Mitigation

Low. The change adds extraction of a field that was previously silently ignored. Plugins that do not export setChannelRuntime are unaffected. The regression test exercises the exact failure mode and fails without the fix.

Linked Issue/PR

Fixes #77779

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/plugins/loader-channel-setup.ts (modified, +6/-0)
  • src/plugins/loader.test.ts (modified, +125/-0)

Code Example

[starting weixin provider (https://ilinkai.weixin.qq.com)]
[waiting for Weixin runtime...]
[waitForWeixinRuntime() failed: Error: Weixin runtime initialization timeout]
[channel exited: Weixin runtime initialization timeout]
[auto-restart attempt N/10 in Xs]

---

Failed to start login: TypeError: fetch failed
Channel login failed: Error: Failed to start login: TypeError: fetch failed

---

register(api) {
    assertHostCompatibility(api.runtime?.version);
    if (api.runtime) {                    // ← api.runtime is undefined in 2026.5.4
        setWeixinRuntime(api.runtime);    // ← never called
    }
    api.registerChannel({ plugin: weixinPlugin });
}

---

2026-05-05T17:06:28.465+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] starting weixin provider (https://ilinkai.weixin.qq.com)
2026-05-05T17:06:28.816+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] notifyStart failed during startup (ignored): TypeError: fetch failed
2026-05-05T17:06:38.479+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] channel exited: Weixin runtime initialization timeout
2026-05-05T17:06:38.483+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] auto-restart attempt 1/10 in 5s
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

After upgrading OpenClaw from 2026.3.x to 2026.5.4, the @tencent-weixin/openclaw-weixin plugin (v2.4.1) fails to start with Weixin runtime initialization timeout and enters an auto-restart crash loop (10 attempts). The root cause is that api.runtime is now undefined in the plugin register() callback, so setWeixinRuntime() is never called.

Steps to reproduce

  1. Install OpenClaw 2026.5.4 (pnpm on Linux)
  2. Install @tencent-weixin/openclaw-weixin v2.4.1 via openclaw plugins install
  3. Configure and enable the WeChat channel
  4. Run openclaw gateway restart
  5. Observe the gateway logs showing repeated Weixin runtime initialization timeout errors

Expected behavior

The WeChat plugin should start successfully, connect to https://ilinkai.weixin.qq.com, and begin long-polling for messages. This worked correctly on OpenClaw 2026.3.x with the same plugin version 2.4.1.

Actual behavior

The plugin enters a crash loop:

[starting weixin provider (https://ilinkai.weixin.qq.com)]
[waiting for Weixin runtime...]
[waitForWeixinRuntime() failed: Error: Weixin runtime initialization timeout]
[channel exited: Weixin runtime initialization timeout]
[auto-restart attempt N/10 in Xs]

Also observed during login attempt:

Failed to start login: TypeError: fetch failed
Channel login failed: Error: Failed to start login: TypeError: fetch failed

Network connectivity to ilinkai.weixin.qq.com is confirmed working (curl and Node.js fetch from CLI both succeed).

Root cause analysis

In the plugin entry point (index.js):

register(api) {
    assertHostCompatibility(api.runtime?.version);
    if (api.runtime) {                    // ← api.runtime is undefined in 2026.5.4
        setWeixinRuntime(api.runtime);    // ← never called
    }
    api.registerChannel({ plugin: weixinPlugin });
}

The monitor then calls waitForWeixinRuntime() which polls for the global pluginRuntime variable — but since setWeixinRuntime() was never called, it always times out after 10 seconds.

In 2026.3.x, api.runtime was populated during register(). In 2026.5.4, it appears to be undefined — likely a breaking change in the plugin SDK.

OpenClaw version

2026.5.4 (325df3e)

Operating system

Linux 6.17.0-22-generic (x64), Node.js v24.15.0

Install method

pnpm (global)

Model

N/A (channel-level issue, not model-specific)

Provider / routing chain

N/A (WeChat channel plugin, not model routing)

Logs, screenshots, and evidence

Gateway log excerpt (repeated ~6 times before giving up):

2026-05-05T17:06:28.465+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] starting weixin provider (https://ilinkai.weixin.qq.com)
2026-05-05T17:06:28.816+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] notifyStart failed during startup (ignored): TypeError: fetch failed
2026-05-05T17:06:38.479+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] channel exited: Weixin runtime initialization timeout
2026-05-05T17:06:38.483+08:00 [openclaw-weixin] [04ec3e0661b8-im-bot] auto-restart attempt 1/10 in 5s

openclaw status --deep output shows channel state as ON | OK despite the crash loop, which may also be worth investigating.

Impact and severity

Affected: All users of @tencent-weixin/openclaw-weixin plugin on OpenClaw 2026.5.4 Severity: High — WeChat channel is completely non-functional, cannot send or receive messages Frequency: 100% reproducible (every startup attempt fails) Consequence: WeChat bot is offline; users relying on WeChat channel for communication are affected

Additional information

  • Last known good version: OpenClaw 2026.3.x (exact version varied, plugin 2.4.1 worked)
  • First known bad version: OpenClaw 2026.5.4
  • Plugin version: @tencent-weixin/openclaw-weixin v2.4.1 (latest on npm)
  • The compatibility table in the plugin README lists >=2026.3.22 as compatible, but 2026.5.4 appears to have a breaking change in the plugin SDK that was not accounted for
  • This may also affect other channel plugins that rely on api.runtime in their register() callback

extent analysis

TL;DR

Update the @tencent-weixin/openclaw-weixin plugin to handle the case where api.runtime is undefined in the register() callback.

Guidance

  • Check the OpenClaw plugin SDK documentation for any changes to the register() callback, specifically regarding the api.runtime property.
  • Modify the plugin's register() function to handle the case where api.runtime is undefined, potentially by using a default value or an alternative method to initialize the Weixin runtime.
  • Verify that the plugin is compatible with OpenClaw version 2026.5.4 by checking the compatibility table in the plugin README and testing with different versions.
  • Consider reaching out to the plugin maintainers or the OpenClaw community for further assistance or guidance on resolving this issue.

Example

register(api) {
    if (api.runtime) {
        setWeixinRuntime(api.runtime);
    } else {
        // Handle the case where api.runtime is undefined
        // potentially by using a default value or an alternative method
        // to initialize the Weixin runtime
        console.log("api.runtime is undefined, using alternative initialization method");
        // alternative initialization code here
    }
    api.registerChannel({ plugin: weixinPlugin });
}

Notes

The exact solution will depend on the specific requirements of the @tencent-weixin/openclaw-weixin plugin and the OpenClaw plugin SDK. It is recommended to consult the documentation and seek guidance from the plugin maintainers or the OpenClaw community if necessary.

Recommendation

Apply a workaround by modifying the plugin's register() function to handle the case where api.runtime is undefined, as shown in the example above. This will allow the plugin to function correctly with OpenClaw version 2026.5.4 until a more permanent solution is available.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The WeChat plugin should start successfully, connect to https://ilinkai.weixin.qq.com, and begin long-polling for messages. This worked correctly on OpenClaw 2026.3.x with the same plugin version 2.4.1.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Bug]: WeChat plugin fails to start — api.runtime undefined in 2026.5.4 causes runtime initialization timeout [1 pull requests, 7 comments, 7 participants]