Skip to content

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

@fdefilippo

Description

@fdefilippo

Description

When loading memory-tencentdb as a non-bundled OpenClaw plugin (auto-discovered after install), the following error occurs during plugin registration:

[plugins] memory-tencentdb failed during register from .../dist/index.mjs:
TypeError: Cannot read properties of undefined (reading 'resolveStateDir')

The error originates at line 16969 of the compiled dist:

const pluginDataDir = path.join(api.runtime.state.resolveStateDir(), "memory-tdai");

api.runtime.state is undefined when the plugin registers before the runtime state is fully initialized.

Environment

  • OpenClaw version: 2026.5.22
  • Plugin: @tencentdb-agent-memory/memory-tencentdb (latest)
  • Install method: npm global install + auto-discovery via plugins.allow empty

Additional Issues Noticed

1. L1 extraction JSON parser greedy regex

The parseExtractionResult function uses a greedy regex /\[[\s\S]*\]/ that captures trailing text when the LLM adds content after the JSON array. This causes JSON.parse failures like:

Failed to parse extraction result: Unexpected non-whitespace character after JSON at position 564

Local fix: replaced with bracket-depth tracking (counting [/{ and ]/}) to find the first complete JSON array and ignore trailing text.

2. EmbeddingService not available

With default config (embedding.provider: "none"), the recall falls back to keyword-only:

Strategy "hybrid" requested but EmbeddingService not available, falling back to keyword

Would be helpful to document which embedding providers/models are supported and how to configure them (e.g. baseUrl, apiKey, model, dimensions requirements).

Expected Behavior

Plugin should either:

  • Gracefully handle resolveStateDir() being unavailable at registration time (e.g. by using a fallback path)
  • Or defer registration until runtime state is available

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions