openclaw - ✅(Solved) Fix fix(discord): voice manager .js import crashes channel provider on startup [1 pull requests, 1 comments, 2 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#50047Fetched 2026-04-08 00:59:53
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Author
Timeline (top)
commented ×1cross-referenced ×1

Root Cause

extensions/discord/src/voice/manager.runtime.ts imports from "./manager.js", but only manager.ts exists on disk. This is the standard TypeScript ESM convention (.js extensions in imports that resolve to .ts at compile time), but the file is loaded at runtime via jiti with tryNative: true. Node's native ESM loader tries to resolve ./manager.js first and fails before jiti can fall back to .ts.

The same pattern exists in extensions/discord/src/channel.runtime.ts (./setup-surface.js).

Fix Action

Fix

Change .js.ts in the import specifiers of *.runtime.ts files that are loaded via jiti at runtime (not compiled to JS). These files are always executed as TypeScript source through the plugin loader.

Note: Many other extensions have the same .js import pattern in their *.runtime.ts files. They may not be crashing yet (perhaps their imports resolve to bundled dist chunks), but they are at risk.

PR fix notes

PR #50048: fix(discord): use .ts imports in runtime files loaded via jiti

Description (problem / solution / changelog)

Summary

  • Fix Discord channel provider crash loop caused by .js imports in *.runtime.ts files that are loaded via jiti at runtime
  • Change ./manager.js./manager.ts and ./setup-surface.js./setup-surface.ts in discord extension runtime files
  • Add extensionAlias to jiti plugin loader options as defense-in-depth for other extensions with the same pattern

Root Cause

*.runtime.ts files are loaded via jiti with tryNative: true. Node's native ESM loader resolves ./manager.js first and fails (file doesn't exist — only manager.ts). Jiti's fallback .ts resolution never runs.

Broken since 3dec814fda (refactor: bundle lazy runtime surfaces, 2026-03-17).

Test plan

  • Gateway starts without Discord channel exited errors
  • Discord logs show logged in to discord as ... (PDD)
  • No more restart loop in gateway logs

Closes #50047

🤖 Generated with Claude Code

Changed files

  • AGENTS.md (modified, +3/-1)
  • extensions/discord/src/channel.runtime.ts (modified, +2/-2)
  • extensions/discord/src/voice/manager.runtime.ts (modified, +1/-1)
  • src/agents/custom-api-registry.ts (modified, +40/-0)
  • src/agents/model-auth.ts (modified, +5/-2)
  • src/agents/pi-embedded-runner/compact.ts (modified, +1/-1)
  • src/agents/pi-embedded-runner/run.ts (modified, +1/-1)
  • src/agents/pi-model-discovery.ts (modified, +2/-0)
  • src/agents/sandbox/tool-policy.ts (modified, +13/-1)
  • src/config/types.discord.ts (modified, +6/-0)
  • src/config/types.tools.ts (modified, +4/-0)
  • src/config/zod-schema.providers-core.ts (modified, +2/-0)
  • src/discord/monitor/allow-list.ts (added, +606/-0)
  • src/discord/monitor/listeners.ts (added, +888/-0)
  • src/discord/monitor/provider.lifecycle.ts (added, +354/-0)
  • src/discord/monitor/provider.ts (added, +831/-0)
  • src/plugins/loader.ts (modified, +4/-0)

Code Example

channel exited: Cannot find module '.../extensions/discord/src/voice/manager.js'
imported from .../extensions/discord/src/voice/manager.runtime.ts
RAW_BUFFERClick to expand / collapse

Bug

The Discord channel provider crashes in a restart loop on every startup with:

channel exited: Cannot find module '.../extensions/discord/src/voice/manager.js'
imported from .../extensions/discord/src/voice/manager.runtime.ts

This prevents Discord from connecting, so DMs and guild messages are not processed.

Root Cause

extensions/discord/src/voice/manager.runtime.ts imports from "./manager.js", but only manager.ts exists on disk. This is the standard TypeScript ESM convention (.js extensions in imports that resolve to .ts at compile time), but the file is loaded at runtime via jiti with tryNative: true. Node's native ESM loader tries to resolve ./manager.js first and fails before jiti can fall back to .ts.

The same pattern exists in extensions/discord/src/channel.runtime.ts (./setup-surface.js).

Breaking Commit

3dec814fdarefactor: bundle lazy runtime surfaces (2026-03-17)

This commit rewrote manager.runtime.ts from a simple re-export to class wrappers, but both versions had the "./manager.js" import. The issue may have been latent before and only surfaced when jiti's tryNative behavior changed or Node 25's ESM resolver became stricter.

Fix

Change .js.ts in the import specifiers of *.runtime.ts files that are loaded via jiti at runtime (not compiled to JS). These files are always executed as TypeScript source through the plugin loader.

Note: Many other extensions have the same .js import pattern in their *.runtime.ts files. They may not be crashing yet (perhaps their imports resolve to bundled dist chunks), but they are at risk.

extent analysis

Fix Plan

To resolve the issue, update the import specifiers in the *.runtime.ts files to use the .ts extension instead of .js. This change ensures that the files are loaded correctly at runtime.

  • Update extensions/discord/src/voice/manager.runtime.ts to import from "./manager.ts" instead of "./manager.js"
  • Update extensions/discord/src/channel.runtime.ts to import from "./setup-surface.ts" instead of "./setup-surface.js"

Example code changes:

// Before
import { Manager } from "./manager.js";

// After
import { Manager } from "./manager.ts";
// Before
import { setupSurface } from "./setup-surface.js";

// After
import { setupSurface } from "./setup-surface.ts";

Verification

After applying the changes, restart the Discord channel provider and verify that it no longer crashes in a restart loop. Check that DMs and guild messages are being processed correctly.

Extra Tips

  • Review other extensions for similar import patterns and update them to use the .ts extension to prevent potential issues.
  • Consider updating the build process to handle the import specifiers correctly, if possible.

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