Skip to content

Windows: Feishu channel fails with 'Feishu runtime not initialized' #50251

@usmsb

Description

@usmsb

Problem

On Windows, the Feishu channel fails to start with error 'Feishu runtime not initialized'.

Root Cause

When jiti loads the Feishu plugin, runtime.ts is loaded twice via different import paths:

  1. index.ts imports from ./src/runtime.js
  2. channel.ts imports from ./runtime

Even though these resolve to the same file, jiti caches them as separate module instances, creating two separate closures with different runtime stores. The setRuntime is called on one instance, but getRuntime reads from another.

Suggested Fix

Use a global variable to share the runtime store across all jiti module instances:

declare global {
  var __feishuRuntimeStore: ReturnType<typeof createPluginRuntimeStore<PluginRuntime>> | undefined;
}

if (!globalThis.__feishuRuntimeStore) {
  globalThis.__feishuRuntimeStore = createPluginRuntimeStore<PluginRuntime>('Feishu runtime not initialized');
}

const _store = globalThis.__feishuRuntimeStore;

Environment

  • OS: Windows
  • Node.js version: 22+
  • OpenClaw version: latest

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