openclaw - ✅(Solved) Fix [Bug]: Plugin discovery via safeRealpathSync takes ~20 minutes during gateway startup on Windows [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#65733Fetched 2026-04-14 05:40:35
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×2cross-referenced ×1

During gateway startup on Windows, the plugin discovery phase spends ~20 minutes repeatedly calling fs.realpathSync (via safeRealpathSync) to resolve paths under ~/.openclaw/extensions and bundled plugin directories, making the chat page initialization extremely slow.

Root Cause

Root cause analysis:

Fix Action

Fixed

PR fix notes

PR #65825: fix(plugins): reuse realpath cache during discovery

Description (problem / solution / changelog)

Summary

  • thread a shared realpathCache through plugin discovery helpers so one discovery pass can reuse safeRealpathSync() results
  • cache the canonical resolved path in safeRealpathSync() so symlinked or canonicalized package roots do not trigger a second low-level fs.realpathSync() lookup
  • add regression coverage for both normal package extension packs and symlinked package roots discovered via extraPaths

Root cause

src/plugins/discovery.ts already used safeRealpathSync(), but discovery never passed a shared cache through its helper stack. That made a single discovery run recompute the same realpaths repeatedly. On Windows npm-global installs, the repeated fs.realpathSync() work during plugin discovery was the reported startup bottleneck in #65733.

Test plan

  • pnpm exec vitest run src/plugins/discovery.test.ts
  • pnpm exec vitest run src/plugins/manifest-registry.test.ts -t "suppresses duplicate warning when candidates share the same physical directory via symlink"
  • pnpm exec vitest run src/plugins/discovery.test.ts src/plugins/manifest-registry.test.ts
  • pnpm build

Notes

  • AI-assisted: yes
  • Testing: fully tested locally for the touched surface

Fixes #65733

Changed files

  • src/plugins/discovery.test.ts (modified, +109/-1)
  • src/plugins/discovery.ts (modified, +43/-8)
  • src/plugins/path-safety.ts (modified, +1/-0)

Code Example

Logs, screenshots, and evidence
Debug call stack (captured via Node.js debugger during initialization):


safeRealpathSync          VM168 ... :282  (path-safety.ts:14 → fs.realpathSync)
addCandidate              VM168 ... :528  (discovery.ts:427)
discoverInDirectory       VM168 ... :691  (discovery.ts:576)
discoverOpenClawPlugins   VM168 ... :912  (discovery.ts:942)
loadPluginManifestRegistry manifest-registry.ts:489
resolvePluginAutoEnableCandidates plugin-auto-enable.detect.ts
detectPluginAutoEnableCandidates plugin-auto-enable.detect.ts
applyPluginAutoEnable     plugin-auto-enable.apply.ts
resolvePluginActivationSnapshot plugin-auto-enable.prefer-over.ts
resolveBundledPluginCompatibleActivationInputs ...
The targetPath being resolved at the breakpoint was:
D:\npm-global\node_modules\openclaw\dist\extensions\xai

Root cause analysis:

discoverOpenClawPlugins recursively scans three directories: stock (bundled), global (~/.openclaw/extensions), and workspace (.openclaw/extensions)
For each directory entry, addCandidate calls safeRealpathSync on the rootDir parameter
safeRealpathSync has a per-call cache parameter that is shared within loadPluginManifestRegistry (see manifest-registry.ts:501), but this cache is NOT shared during the discoverOpenClawPlugins phase
discoverOpenClawPlugins calls safeRealpathSync at multiple points (lines 146, 147, 339, 340, 427, 576) without passing any shared cache — each call resolves the realpath independently
On Windows, fs.realpathSync is significantly slower than on Unix, especially for paths under npm global directories
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

During gateway startup on Windows, the plugin discovery phase spends ~20 minutes repeatedly calling fs.realpathSync (via safeRealpathSync) to resolve paths under ~/.openclaw/extensions and bundled plugin directories, making the chat page initialization extremely slow.

Steps to reproduce

Install OpenClaw 2026.4.12-beta.1 globally via npm on Windows 10: npm install -g openclaw Start the OpenClaw gateway Open the chat page and connect to the gateway Observe ~20 minutes of initialization delay Debug in Node.js debugger and pause — call stack shows:

safeRealpathSync (path-safety.ts:14) → fs.realpathSync addCandidate (discovery.ts:427) discoverInDirectory (discovery.ts:576) discoverOpenClawPlugins (discovery.ts:942) loadPluginManifestRegistry (manifest-registry.ts:491) resolvePluginAutoEnableCandidates detectPluginAutoEnableCandidates applyPluginAutoEnable resolvePluginActivationSnapshot resolveBundledPluginCompatibleActivationInputs ...

Expected behavior

Plugin discovery should complete within seconds, similar to Linux/macOS. The gateway should be ready to accept chat connections shortly after startup.

Actual behavior

Initialization takes ~20 minutes. The debugger shows the bottleneck is safeRealpathSync in src/plugins/path-safety.ts:14, which calls fs.realpathSync for every file and directory encountered during recursive plugin discovery. On Windows, fs.realpathSync appears to be very slow when traversing the npm global install directory.

OpenClaw version

2026.4.12-beta.1

Operating system

Windows 10 Home 10.0.19045

Install method

npm global (D:\npm-global\node_modules\openclaw)

Model

local

Provider / routing chain

whalecloud/LOCAL/Qwen3.5-122B-A10B

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Logs, screenshots, and evidence
Debug call stack (captured via Node.js debugger during initialization):


safeRealpathSync          VM168 ... :282  (path-safety.ts:14 → fs.realpathSync)
addCandidate              VM168 ... :528  (discovery.ts:427)
discoverInDirectory       VM168 ... :691  (discovery.ts:576)
discoverOpenClawPlugins   VM168 ... :912  (discovery.ts:942)
loadPluginManifestRegistry manifest-registry.ts:489
resolvePluginAutoEnableCandidates plugin-auto-enable.detect.ts
detectPluginAutoEnableCandidates plugin-auto-enable.detect.ts
applyPluginAutoEnable     plugin-auto-enable.apply.ts
resolvePluginActivationSnapshot plugin-auto-enable.prefer-over.ts
resolveBundledPluginCompatibleActivationInputs ...
The targetPath being resolved at the breakpoint was:
D:\npm-global\node_modules\openclaw\dist\extensions\xai

Root cause analysis:

discoverOpenClawPlugins recursively scans three directories: stock (bundled), global (~/.openclaw/extensions), and workspace (.openclaw/extensions)
For each directory entry, addCandidate calls safeRealpathSync on the rootDir parameter
safeRealpathSync has a per-call cache parameter that is shared within loadPluginManifestRegistry (see manifest-registry.ts:501), but this cache is NOT shared during the discoverOpenClawPlugins phase
discoverOpenClawPlugins calls safeRealpathSync at multiple points (lines 146, 147, 339, 340, 427, 576) without passing any shared cache — each call resolves the realpath independently
On Windows, fs.realpathSync is significantly slower than on Unix, especially for paths under npm global directories

Impact and severity

Affected: All OpenClaw users on Windows using npm global install Severity: High — renders the chat UI nearly unusable (20 min wait per startup/reload) Frequency: Always on Windows with this install method Consequence: Users must wait ~20 minutes for gateway initialization before they can interact with the chat interface

Additional information

There is no configuration option to skip or disable the plugin discovery phase. plugins.enabled: false in config only prevents plugin loading, not discovery — the discovery runs before the plugins.enabled check. Environment variables like OPENCLAW_PLUGIN_DISCOVERY_CACHE_MS only control the short TTL cache (default 1 second) for collapsing bursty repeated discovery calls, but do not help with the initial slow fs.realpathSync calls during the first discovery run.

Potential fix direction: consider sharing the realpath cache between discoverOpenClawPlugins and loadPluginManifestRegistry, or skip realpathSync for bundled plugin paths that are known to be safe and don't contain symlinks.

extent analysis

TL;DR

The most likely fix is to share the realpath cache between discoverOpenClawPlugins and loadPluginManifestRegistry or skip realpathSync for bundled plugin paths.

Guidance

  • Investigate sharing the realpath cache between discoverOpenClawPlugins and loadPluginManifestRegistry to reduce repeated fs.realpathSync calls.
  • Consider skipping realpathSync for bundled plugin paths that are known to be safe and don't contain symlinks.
  • Review the safeRealpathSync function in path-safety.ts to see if any optimizations can be made for Windows-specific paths.
  • Test the fix on Windows with the npm global install method to verify the initialization delay is significantly reduced.

Example

No code example is provided as the issue requires a deeper understanding of the OpenClaw codebase and the safeRealpathSync function.

Notes

The fix may require modifications to the discoverOpenClawPlugins and loadPluginManifestRegistry functions to share the realpath cache or skip realpathSync for certain paths. Additionally, the performance of the fix should be tested on different Windows environments to ensure it resolves the issue.

Recommendation

Apply a workaround by sharing the realpath cache between discoverOpenClawPlugins and loadPluginManifestRegistry or skipping realpathSync for bundled plugin paths, as this is likely to significantly reduce the initialization delay on Windows.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Plugin discovery should complete within seconds, similar to Linux/macOS. The gateway should be ready to accept chat connections shortly after startup.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING