openclaw - 💡(How to fix) Fix DefaultResourceLoader.reload() blocks event loop for 12-15s on Windows due to synchronous filesystem scanning

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…

Root Cause

DefaultResourceLoader.reload() from @mariozechner/pi-coding-agent blocks the Node.js event loop for 12-15 seconds on every agent run on Windows/NTFS. This is caused by extensive use of synchronous filesystem operations:

Code Example

prep stages: totalMs=14809 stages=workspace-sandbox:1ms,skills:1ms,core-plugin-tools:2199ms,bootstrap-context:17ms,bundle-tools:790ms,system-prompt:4ms,session-resource-loader:11787ms@14799ms,agent-session:2ms,stream-setup:8ms
RAW_BUFFERClick to expand / collapse

Problem

DefaultResourceLoader.reload() from @mariozechner/pi-coding-agent blocks the Node.js event loop for 12-15 seconds on every agent run on Windows/NTFS. This is caused by extensive use of synchronous filesystem operations:

  • readdirSync, statSync, readFileSync, existsSync — 21+ occurrences in resource-loader.js, 15+ in discovery-CVL9-KJt.js
  • These scan directories recursively across multiple locations on every reload() call

Directories scanned on every reload()

  • ~/.openclaw/extensions, ~/.openclaw/skills, ~/.openclaw/prompts, ~/.openclaw/themes
  • <workspace>/.openclaw/extensions, <workspace>/.openclaw/skills, etc.
  • ~/.agents/skills
  • Ancestor directory scanning via collectAncestorAgentsSkillDirs()
  • All npm package resolution paths

Impact

  • Event loop blocked: eventLoopDelayP99Ms=12297ms, eventLoopUtilization=1.0
  • Tool call timeouts: GatewayTransportError: gateway timeout after 10000ms
  • Duplicate Telegram messages: Preview cleanup queued behind blocked event loop
  • Slow WebSocket responses: chat.history 200-3800ms, node.list 248-2258ms
  • Subagent spawns: Every subagent also pays the 12s overhead

Log evidence

prep stages: totalMs=14809 stages=workspace-sandbox:1ms,skills:1ms,core-plugin-tools:2199ms,bootstrap-context:17ms,bundle-tools:790ms,system-prompt:4ms,session-resource-loader:11787ms@14799ms,agent-session:2ms,stream-setup:8ms

session-resource-loader alone accounts for 80% of prep time.

Environment

  • OpenClaw: 2026.5.7 (eeef486)
  • OS: Windows 10 (26200), NTFS
  • Node: v24.13.0
  • .openclaw directory: 14,560 files
  • Workspace skills: 64 files (after archiving 21 unused)

Proposed fixes

  1. Cache resource discovery results between runs — only rescan when file mtimes change
  2. Convert sync fs to async with fs.promises.* (though the reload must complete before the run starts, so this alone would not reduce total time — but it would stop blocking the event loop)
  3. Expose skip flagsDefaultResourceLoader already supports noExtensions, noSkills, noThemes, noPromptTemplates, noContextFiles constructor options, but OpenClaw does not expose these via config. Adding config options like agents.defaults.skipResourceTypes: ["themes", "prompts"] would let users opt out of unused resource types.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix DefaultResourceLoader.reload() blocks event loop for 12-15s on Windows due to synchronous filesystem scanning