openclaw - ✅(Solved) Fix Config hot-reload does not watch $include-referenced files [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#59616Fetched 2026-04-08 02:42:31
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
referenced ×2cross-referenced ×1

startGatewayConfigReloader in src/gateway/config-reload.ts only watches the main config file (watchPath). When users split their config with $include directives (supported by src/config/includes.ts), edits to the included files do not trigger hot-reload — changes are silently ignored until a manual restart.

Root Cause

chokidar.watch(opts.watchPath, ...) monitors a single file path. The $include resolution (in src/config/includes.ts) merges referenced files during config read, but the reloader never learns about those file paths.

Fix Action

Fixed

PR fix notes

PR #59632: feat: watch $include-referenced files for config hot-reload

Description (problem / solution / changelog)

Fixes #59616 Relates to #41587

Problem

startGatewayConfigReloader only watches the main config file via chokidar. Users who split their config using $include directives (supported by src/config/includes.ts) must manually restart the gateway after editing included files — changes are silently ignored.

Solution

Reuse the existing collectIncludePathsRecursive() from src/config/includes-scan.ts to dynamically track $include-referenced files:

  1. On startup: read the main config file, resolve all $include paths, and watcher.add() them
  2. After each successful reload: re-collect include paths, diff against the current set, watcher.add() new paths and watcher.unwatch() removed paths

The sync is best-effort — failures are silently caught and do not disrupt the reload cycle.

Changes

  • src/gateway/config-reload.ts: Add syncIncludeWatchPaths() helper, call it after successful snapshot apply and on startup (+65 lines)
  • src/gateway/config-reload.test.ts: Add 3 tests — include path watching, unwatch on removal, graceful failure (+119 lines)

Tests

32/32 passing (29 existing + 3 new), pnpm check clean.

Changed files

  • src/gateway/config-reload.test.ts (modified, +264/-8)
  • src/gateway/config-reload.ts (modified, +86/-0)
RAW_BUFFERClick to expand / collapse

Description

startGatewayConfigReloader in src/gateway/config-reload.ts only watches the main config file (watchPath). When users split their config with $include directives (supported by src/config/includes.ts), edits to the included files do not trigger hot-reload — changes are silently ignored until a manual restart.

Root cause

chokidar.watch(opts.watchPath, ...) monitors a single file path. The $include resolution (in src/config/includes.ts) merges referenced files during config read, but the reloader never learns about those file paths.

Existing infrastructure

src/config/includes-scan.ts already exports collectIncludePathsRecursive() which recursively resolves all $include paths from a parsed config object (with cycle detection and depth limiting). chokidar supports dynamic watcher.add() / watcher.unwatch().

Suggested fix

After each successful config snapshot read, call collectIncludePathsRecursive and diff against the currently watched set. watcher.add() new paths, watcher.unwatch() removed paths.

Related: #41587

extent analysis

TL;DR

Modify the startGatewayConfigReloader to dynamically watch included config files using chokidar and collectIncludePathsRecursive.

Guidance

  • Identify the current implementation of startGatewayConfigReloader in src/gateway/config-reload.ts and modify it to call collectIncludePathsRecursive after each successful config snapshot read.
  • Use the result of collectIncludePathsRecursive to diff against the currently watched set of paths and update the chokidar watcher accordingly using watcher.add() and watcher.unwatch().
  • Ensure that the collectIncludePathsRecursive function is properly integrated with the config reload mechanism to handle changes to included files.
  • Verify that the updated implementation correctly handles added and removed included files.

Example

import { collectIncludePathsRecursive } from 'src/config/includes-scan';

// ...

const currentWatchedPaths = new Set();
const watcher = chokidar.watch(opts.watchPath, ...);

// After each successful config snapshot read
const includedPaths = collectIncludePathsRecursive(parsedConfig);
const newPaths = includedPaths.filter(path => !currentWatchedPaths.has(path));
const removedPaths = Array.from(currentWatchedPaths).filter(path => !includedPaths.includes(path));

newPaths.forEach(path => watcher.add(path));
removedPaths.forEach(path => watcher.unwatch(path));

currentWatchedPaths = new Set(includedPaths);

Notes

This solution assumes that the collectIncludePathsRecursive function correctly resolves all included file paths and that the chokidar watcher is properly configured to handle dynamic path additions and removals.

Recommendation

Apply workaround: Modify the startGatewayConfigReloader to dynamically watch included config files using chokidar and collectIncludePathsRecursive, as this will allow for hot-reloading of changes to included files without requiring a manual restart.

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