Skip to content

fix(openclaw): tolerate missing state dir resolver#182

Open
RerankerGuo wants to merge 1 commit into
TencentCloud:mainfrom
RerankerGuo:fix/register-state-dir-fallback
Open

fix(openclaw): tolerate missing state dir resolver#182
RerankerGuo wants to merge 1 commit into
TencentCloud:mainfrom
RerankerGuo:fix/register-state-dir-fallback

Conversation

@RerankerGuo

Copy link
Copy Markdown

Description | 描述

Harden OpenClaw state directory resolution during plugin registration.

When OpenClaw loads the plugin before runtime.state is fully initialized, state directory lookup should not make registration fail. This change keeps the existing priority order but makes it more defensive:

  • use runtime.state.resolveStateDir() when available,
  • fall back to OPENCLAW_STATE_DIR when the runtime state is missing, empty, or throws,
  • fall back to ~/.openclaw when no host-provided state directory is available.

Added focused tests for runtime, environment, throwing resolver, and default fallback paths.

Related Issue | 关联 Issue

Fix #89

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过
  • No existing features affected | 无影响现有功能

Additional Notes | 其他说明

Verified with npm test and npm run build using Node v24.15.0.

Signed-off-by: Ziyang Guo <121015044+RerankerGuo@users.noreply.github.com>
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Making plugin registration more resilient to uninitialized runtime is an important stability fix. The multiple fallback layers provide good coverage. We'll review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of undefined (reading 'resolveStateDir') on plugin register

2 participants