openclaw - 💡(How to fix) Fix Discord subagent_ended hook fails with ERR_MODULE_NOT_FOUND

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…

In Docker-era OpenClaw builds, the Discord subagent_ended hook can fail with ERR_MODULE_NOT_FOUND when a subagent run completes in a Discord-bound session. The parent reply may still arrive, but the hook path fails noisily and any intended side effects are lost.

Error Message

The gateway logs an error like: [hooks] subagent_ended handler from discord failed: Error [ERR_MODULE_NOT_FOUND]:

Root Cause

Even when the parent reply still arrives, this indicates the Discord completion path is partially broken. It may also overlap with newer direct-announce failures seen in native 2026.5.12 installs.

Code Example

[hooks] subagent_ended handler from discord failed: Error [ERR_MODULE_NOT_FOUND]:
  Cannot find package 'openclaw' imported from
  /app/dist/extensions/discord/token-D-w3Rigl.js
RAW_BUFFERClick to expand / collapse

Summary

In Docker-era OpenClaw builds, the Discord subagent_ended hook can fail with ERR_MODULE_NOT_FOUND when a subagent run completes in a Discord-bound session. The parent reply may still arrive, but the hook path fails noisily and any intended side effects are lost.

Environment

  • Observed image: ghcr.io/openclaw/openclaw:2026.4.15
  • Channel: Discord-bound session
  • Trigger: subagent completion (sessions_spawn from a Discord session)

Reproduction

  1. Use a Discord-bound agent session.
  2. Trigger any subagent run via sessions_spawn.
  3. Wait for the child run to finish.
  4. Inspect gateway logs.

Actual

The gateway logs an error like:

[hooks] subagent_ended handler from discord failed: Error [ERR_MODULE_NOT_FOUND]:
  Cannot find package 'openclaw' imported from
  /app/dist/extensions/discord/token-D-w3Rigl.js

In the observed Docker-era case, the final assistant reply still reached Discord, so the visible behavior was "works but noisy logs," with the hook's intended side effects silently lost.

Expected

The Discord subagent_ended hook should load successfully and process completion events without module-resolution failures.

Why this matters

Even when the parent reply still arrives, this indicates the Discord completion path is partially broken. It may also overlap with newer direct-announce failures seen in native 2026.5.12 installs.

Likely cause

The Discord extension appears to load a dynamic module that imports openclaw as a bare package specifier from a context where Node cannot resolve it.

Suggested fix

  • Replace the failing import with a resolvable bundled or relative path.
  • Or ship the extension with the package metadata/runtime linkage it needs.
  • Or route hook handling through a host-provided callback instead of direct package import from the extension bundle.

Consolidation question

Please advise whether this should be consolidated with #83352 or kept as a linked but distinct issue:

  • #83352 is a newer native-install failure where direct announce fails and the child is orphan-pruned.
  • This issue is the older Docker-era ERR_MODULE_NOT_FOUND hook signature.

They may share a root cause in the subagent completion delivery path, but the visible failure modes differ.

Notes

Primary AoAOS doc:

  • docs/upstream-bugs/discord-subagent-ended-hook.md

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…

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 - 💡(How to fix) Fix Discord subagent_ended hook fails with ERR_MODULE_NOT_FOUND