Fix #1639: [memos-local-openclaw] Memory Viewer (port 18799) not starting on Node 24#1823
Open
Memtensor-AI wants to merge 1 commit into
Open
Fix #1639: [memos-local-openclaw] Memory Viewer (port 18799) not starting on Node 24#1823Memtensor-AI wants to merge 1 commit into
Memtensor-AI wants to merge 1 commit into
Conversation
…#1639) On OpenClaw runtimes that do not expose `api.on` (or expose one that throws), the call to `api.on("before_prompt_build", ...)` raised partway through `register()` and aborted the rest of plugin setup. The ViewerServer was never instantiated, `api.registerService` never ran, and the `setTimeout(0)` self-start fallback was never scheduled — so port 18799 stayed unbound while individual tools (registered earlier) kept working. This matched the reported behaviour on Node 24: register/activate succeeds, memory tools work, but the viewer HTTP server never listens. Make the plugin defensive against partial host APIs: - Add a `safeOn` helper that checks for `api.on` and wraps the invocation in try/catch; reroute both `before_prompt_build` and `agent_end` through it. - Wrap `api.registerMemoryCapability` and `api.registerService` in try/catch with existence checks, so missing methods log a warning instead of throwing. - Track whether registerService succeeded so the existing setTimeout(0) fallback can log the right reason when it self-starts the viewer. Also add two regression tests in `plugin-openclaw-wiring.test.ts`: one for the `api.on === undefined` case and one for an `api.on` that throws synchronously. Both assert that ViewerServer is still constructed (and, for the missing-on variant, started) during `register()`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Description
修复了 #1639:memos-local-openclaw 插件的 register() 在调用 api.on("before_prompt_build", ...) 时抛错(老/兼容版 OpenClaw runtime 不提供 api.on),导致后续 ViewerServer 实例化、registerService 注册、setTimeout(0) 自启动兜底都没有执行,端口 18799 永远未绑定。修复:新增 safeOn 包裹两处 api.on,并把 registerMemoryCapability / registerService 也用存在性检查 + try/catch 兜住;另加 2 个回归测试覆盖 api.on 缺失和 api.on 抛错两种场景。已 commit + push 到 autodev/MemOS-1639,scheduler 可基于此分支兜底创建 PR。
Related Issue (Required): Fixes #1639
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Executor did not report tests.
Checklist
@CarltonXiang, @syzsunshine219 please review this PR.
Reviewer Checklist