fix: 修复 register() 重入导致 compat 和 runtime 日志重复输出#47
Open
neo1027144-creator wants to merge 1 commit intoTencent:mainfrom
Open
fix: 修复 register() 重入导致 compat 和 runtime 日志重复输出#47neo1027144-creator wants to merge 1 commit intoTencent:mainfrom
neo1027144-creator wants to merge 1 commit intoTencent:mainfrom
Conversation
When the OpenClaw host invokes register() multiple times (e.g. during config hot-reload or model list refresh), the compat OK and runtime set logs were emitted at info level every time, causing significant log spam. This change: - compat.ts: tracks already-checked host versions in a module-level Set; subsequent checks for the same version are logged at debug instead of info. - runtime.ts: tracks whether runtime has been initialized; subsequent re-entrant calls are logged at debug instead of info. First-time initialization continues to log at info level as before. Closes Tencent#46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
Fixes #46
OpenClaw 宿主在配置热重载、模型列表刷新、控制台重连等场景下会多次调用插件的
register(),导致以下两条初始化日志每次都以info级别重复输出:[compat] Host OpenClaw 2026.4.5 >= 2026.3.22, OK.[runtime] setWeixinRuntime called, runtime set successfully这会产生大量日志噪音,干扰排查真正的异常信息。
修复方案
对两处日志做进程内去重,首次输出保持
info级别不变,后续重入调用降级为debug:src/compat.tsSet<string>记录已检查过的宿主版本info(行为不变)debugsrc/runtime.tsboolean标记是否已完成首次初始化setWeixinRuntime()调用:info(行为不变)debug测试验证
state-dir、sync-buf),与本次修改无关(Windows 路径分隔符和超时问题)