openclaw - ✅(Solved) Fix [Bug]: ReferenceError: Cannot access 'utils_1' before initialization when mentioning bot in Feishu group [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#64783Fetched 2026-04-12 13:26:52
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
referenced ×2commented ×1cross-referenced ×1labeled ×1

When mentioning (@) a bot in a Feishu group chat, the openclaw-lark plugin throws 'ReferenceError: Cannot access utils_1 before initialization', preventing the bot from responding.

Error Message

19:03:34 [feishu] feishu[bot-ops-li]: error handling message: ReferenceError: Cannot access 'utils_1' before initialization

Error occurs when mentioning a bot in a Feishu group chat configured with multi-agent routing.

Root Cause

When mentioning (@) a bot in a Feishu group chat, the openclaw-lark plugin throws 'ReferenceError: Cannot access utils_1 before initialization', preventing the bot from responding.

Fix Action

Fixed

PR fix notes

PR #64820: fix(feishu): break circular module init causing ReferenceError on group mention

Description (problem / solution / changelog)

Summary

Fixes #64783

When mentioning (@) a bot in a Feishu group chat with multi-agent configuration, the gateway throws:

ReferenceError: Cannot access 'utils_1' before initialization

Root cause: monitor.account.ts statically imports handleFeishuMessage and parseFeishuMessageEvent from bot.ts, which pulls in a deep transitive dependency tree (bot-content -> post -> comment-shared -> plugin-sdk/text-runtime, plus policy, reply-dispatcher, dedup, etc.). When tsdown/esbuild bundles these into a single output chunk, the shared utility bindings can violate the Temporal Dead Zone — the bundler evaluates one module scope before the utility variable it references has been initialized.

Fix (3 changes):

  • Extract parseFeishuMessageEvent into a new lightweight message-parser.ts module that only depends on shallow modules (bot-content, mention, event-types, types) — no heavy transitive deps
  • Lazy-load handleFeishuMessage and handleFeishuCardAction in monitor.account.ts via dynamic import() instead of static imports, deferring evaluation of bot.ts and card-action.ts until the first event is dispatched
  • Update sequential-key.ts to import from message-parser.ts instead of bot.ts
  • bot.ts re-exports parseFeishuMessageEvent for full backward compatibility

Test plan

  • Added message-parser.test.ts with:
    • Unit tests for parseFeishuMessageEvent (basic parsing, bot mention detection, mention forward detection, sender fields, thread IDs)
    • Backward compatibility test verifying bot.ts re-export is the same function reference
    • Module isolation tests verifying message-parser.ts does not import from bot.ts, and monitor.account.ts uses dynamic import for bot.ts
  • Existing tests (bot.checkBotMentioned.test.ts, bot.stripBotMention.test.ts, sequential-key.test.ts, etc.) continue to pass since bot.ts re-exports the function
  • Manual test: configure multi-agent Feishu setup, mention a bot in a group chat — no more ReferenceError

🤖 Generated with Claude Code

Changed files

  • extensions/feishu/src/bot.ts (modified, +2/-54)
  • extensions/feishu/src/message-parser.test.ts (added, +203/-0)
  • extensions/feishu/src/message-parser.ts (added, +87/-0)
  • extensions/feishu/src/monitor.account.ts (modified, +45/-12)
  • extensions/feishu/src/sequential-key.ts (modified, +2/-1)

Code Example

19:03:34 [feishu] feishu[bot-ops-li]: error handling message: ReferenceError: Cannot access 'utils_1' before initialization


Error occurs when mentioning a bot in a Feishu group chat configured with multi-agent routing.
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When mentioning (@) a bot in a Feishu group chat, the openclaw-lark plugin throws 'ReferenceError: Cannot access utils_1 before initialization', preventing the bot from responding.

Steps to reproduce

  1. Configure multiple Feishu bots (e.g., bot-sansui, bot-ops-li) in openclaw.json
  2. Create a Feishu group and configure routing to one agent (e.g., sansui)
  3. In the group, mention (@) another bot (e.g., @运维小李)
  4. Observe Gateway log showing: 19:03:34 [feishu] feishu[bot-ops-li]: error handling message: ReferenceError: Cannot access 'utils_1' before initialization

Expected behavior

The mentioned bot should receive and process the message normally, responding in the group chat without throwing initialization errors.

Actual behavior

Gateway throws ReferenceError: Cannot access 'utils_1' before initialization and the mentioned bot fails to respond. The error occurs in the openclaw-lark plugin's message handling logic. Manual code inspection shows no circular dependencies in utils.js, suggesting a module loading order issue specific to group chat mention handling.

OpenClaw version

2026.3.18 (openclaw-lark plugin version)

Operating system

Windows 10 (10.0.22621)

Install method

npm global

Model

ccvibe/claude-opus-4-6

Provider / routing chain

openclaw -> ccvibe (custom provider)

Additional provider/model setup details

Logs, screenshots, and evidence

19:03:34 [feishu] feishu[bot-ops-li]: error handling message: ReferenceError: Cannot access 'utils_1' before initialization


Error occurs when mentioning a bot in a Feishu group chat configured with multi-agent routing.

Impact and severity

  • Affected: Users with multi-agent Feishu setups using group chat mentions
  • Severity: High (blocks bot responses in group chats)
  • Frequency: 100% reproducible when mentioning bots in configured groups
  • Consequence: Bots fail to respond to mentions, breaking multi-agent collaboration workflows

Additional information

  • Manual inspection of utils.js confirmed no circular dependencies
  • Error only occurs when mentioning bots in group chats, not in direct messages
  • Normal messages (without mentions) work fine in the same group
  • This appears to be a module initialization order issue in openclaw-lark plugin
  • Attempted to use madge for dependency analysis but npm install failed
  • Gateway restart does not resolve the issue

extent analysis

TL;DR

The issue can likely be resolved by adjusting the module loading order in the openclaw-lark plugin to ensure that utils_1 is initialized before it is accessed.

Guidance

  • Verify that there are no circular dependencies in the code by using a dependency analysis tool, as manual inspection may not be sufficient.
  • Check the openclaw-lark plugin's code to see if utils_1 is being imported or required before it is initialized, and adjust the import order if necessary.
  • Consider using a tool like madge for dependency analysis, but ensure it is installed and configured correctly to avoid installation failures.
  • Test the fix by mentioning a bot in a Feishu group chat and verifying that the bot responds correctly without throwing the ReferenceError.

Example

No specific code example can be provided without more information about the openclaw-lark plugin's code, but the fix will likely involve adjusting the order of imports or requires in the plugin's code.

Notes

The issue appears to be specific to the openclaw-lark plugin and its handling of group chat mentions, and may not be related to the Feishu platform or the ccvibe provider. The fact that normal messages work fine in the same group suggests that the issue is isolated to the mention handling logic.

Recommendation

Apply a workaround by adjusting the module loading order in the openclaw-lark plugin, as this is likely to resolve the issue without requiring an upgrade to a fixed version.

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 mentioned bot should receive and process the message normally, responding in the group chat without throwing initialization errors.

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]: ReferenceError: Cannot access 'utils_1' before initialization when mentioning bot in Feishu group [1 pull requests, 1 comments, 2 participants]