abhigyanpatwari/GitNexus · error · WatchControlReloadError

Ignore controls remain invalid; fix them before indexing mor

Error message

Ignore controls remain invalid; fix them before indexing more changes.

What it means

Wrapped in WatchControlReloadError by startWatchFileLoop in watch.ts when the watch ignore predicate (ignore-file/ignore-pattern controls) fails to reload and the loop is in its retrying pass — i.e. the ignore controls were already invalid once, the watcher retried, and they are still broken. Indexing more changes with broken ignore controls is refused to avoid indexing files the user meant to exclude.

Source

Thrown at gitnexus/src/cli/watch.ts:264

  repoPath: string,
  debounceMs: number,
  refresh: (paths: readonly string[]) => Promise<void>,
  onError: WatchRefreshError,
  onWatcherError: (error: unknown) => void = (error) => onError(error, []),
): Promise<WatchFileLoop> {
  let ignorePath = await createWatchIgnorePredicate(repoPath);
  let ignoreControlValid = true;
  const queue = new WatchRefreshQueue(
    async (paths) => {
      if (paths.some(isIgnoreControlPath) || !ignoreControlValid) {
        const retryingInvalidControls = !ignoreControlValid;
        try {
          ignorePath = await createWatchIgnorePredicate(repoPath);
          ignoreControlValid = true;
          watcher.add(repoPath);
        } catch (error) {
          ignoreControlValid = false;
          throw new WatchControlReloadError(
            retryingInvalidControls
              ? new Error(
                  'Ignore controls remain invalid; fix them before indexing more changes.',
                  {
                    cause: error,
                  },
                )
              : error,
          );
        }
      }
      await refresh(paths);
    },
    onError,
    debounceMs,
    {
      maxWaitMs: Math.max(2_000, debounceMs * 10),
      maxPendingPaths: 1_000,

View on GitHub (pinned to 52924ef12c)

Solutions

  1. Fix the ignore control file: repair or remove the invalid pattern(s) that broke createWatchIgnorePredicate.
  2. Restore the ignore file if it was deleted or moved (restore permissions: readable by the watch process).
  3. Validate patterns with git check-ignore or a glob tester before saving while the watcher is running.
  4. Restart `analyze --watch` after fixing; the loop only recovers once the controls parse successfully.

Example fix

// before (.gitnexusignore while watcher runs)
**/[invalid

// after
**/dist/
**/*.log
Defensive patterns

Strategy: try-catch

Validate before calling

import ignore from 'ignore';
export function validateIgnoreControls(repoRoot: string): void {
  const ig = ignore();
  ig.add(fs.readFileSync(path.join(repoRoot, '.gitnexusignore'), 'utf8')); // throws on bad patterns
}

Try / catch

watchLoop.on('error', (e) => {
  if (e instanceof WatchControlReloadError && /Ignore controls remain invalid/.test(e.message)) {
    console.error('Fix ignore patterns (see cause), then restart watch:', e.cause);
    process.exitCode = 1;
  } else throw e;
});

Prevention

When it happens

Trigger: createWatchIgnorePredicate(repoPath) throws on the retry after a previous failure — typically because the ignore file is malformed, unreadable, was deleted, or contains invalid patterns, and the error surfaces during watch-loop rearming.

Common situations: Editing .gitignore / the gitnexus ignore control file while `analyze --watch` runs and saving a syntax error; deleting or chmod-ing the ignore file; a pattern the parser rejects (e.g. bad glob).

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@52924ef12c (2026-09-01). Data as JSON: /api/errors/85722ca8c5f20dd1. Report an issue: GitHub.