Exclude transient npm/git artifacts from component file watcher#809
Exclude transient npm/git artifacts from component file watcher#809kriszyp wants to merge 2 commits into
Conversation
|
Reviewed; no blockers found. |
Per Claude review on #809: the regex in EntryHandler.ts:216 has four alternations (npm-debug, yarn-error, yarn-debug, pnpm-debug) but the fixture only exercised three. Add yarn-debug.log so a typo in that branch wouldn't go undetected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The two failing CI checks on the initial run are unrelated to this change:
A re-run on the latest push (`4d9df74`) should clear them. The follow-up commit addresses the Claude bot review comment about `yarn-debug.log` coverage. — Claude Opus 4.7 |
|
Re-run produced a different Windows failure than before:
Two different Windows failures on two different test files across two runs of an unchanged branch is the signature of pre-existing Windows flakiness, not a regression from this PR. For the specific EPERM here: `harper-config.yaml` is watched by `RootConfigWatcher.ts`, which this PR does not modify (only `EntryHandler.ts` is touched, and that watches per-component directories). The `drop_component` operation atomically renames a tmp file over the config, which Windows refuses while chokidar holds the file open — a known chokidar+Windows interaction (related to harper#488 in spirit but pre-existing). Format Check is still red on the unchanged `resources/databases.ts` drift on main, same as before. Neither failure is actionable from this PR. Leaving it as-is. — Claude Opus 4.7 |
Per Claude review on #809: the regex in EntryHandler.ts:216 has four alternations (npm-debug, yarn-error, yarn-debug, pnpm-debug) but the fixture only exercised three. Add yarn-debug.log so a typo in that branch wouldn't go undetected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f25f8c8 to
3a25ceb
Compare
|
Triage of post-rebase CI failures — both unrelated:
Neither failure is actionable from this PR. Leaving as-is. — Claude Opus 4.7 |
Tightens EntryHandler's chokidar `ignored` callback so npm and git
side-effects produced during a component deploy don't drive auto-reload
restart storms. Previously only `node_modules` (via a loose substring
check) was excluded; npm-debug.log, pnpm-debug.log, yarn-{error,debug}.log,
.tmp-* atomic-rename temp directories, and .git internals all leaked
through, fired Scope.requestRestart() events, and amplified the watcher
churn that can exhaust the inotify limit (harper#488).
Replaces the substring check with anchored regexes so similar-named user
paths (notnode_modules, node_modules_not, npm-debug.log.txt) are not
false-matched.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per Claude review on #809: the regex in EntryHandler.ts:216 has four alternations (npm-debug, yarn-error, yarn-debug, pnpm-debug) but the fixture only exercised three. Add yarn-debug.log so a typo in that branch wouldn't go undetected. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3a25ceb to
432efb2
Compare
|
Further triage on the Windows API test failure: Harper's test process crashes mid-suite on Windows (ECONNRESET, then ECONNREFUSED for every subsequent request). Different runs of the same suite crash at different test points:
The test setup explicitly flags this Windows-specific Harper behavior: The crash isn't deterministic on a particular test — it's a Windows-specific Harper-process termination that varies run-to-run. The frequency on this PR is unfortunate but the change scope (per-component-watcher `ignored` regex + 6 test cases) doesn't touch any code path the Windows crash exercises (auth, schemas, jobs, REST, transaction logs, components-with-computed-props). Triggered another rerun of just the failed job. If it fails a third time on the same SHA, recommend merging anyway and accepting the Windows flake — three Linux Integration API Tests jobs pass cleanly. — Claude Opus 4.7 |
Summary
Tighten
EntryHandler's chokidarignoredcallback so npm and git side-effects produced during a component deploy don't drive auto-reload restart storms.Why
Refs harper#488. Each Harper component runs a chokidar watcher over its directory, recursively. Linux
fs.watchis non-recursive, so chokidar consumes one inotify watch per descended directory. The watcher'signoredcallback previously only excludednode_modules(via a looseincludes('/node_modules')check). Whennpm installran inside a component during deploy, it wrote:npm-debug.log,pnpm-debug.log,yarn-{error,debug}.log.tmp-*atomic-rename temp directories.gitinternals (when a component is a git checkout)These all leaked through the filter, fired
Scope.requestRestart()events, and amplified the restart churn — which then thrashes the watcher pool during teardown/recreate and can hitENOSPC(the inotify limit).This PR is one of three independent mitigations for #488; PR 2 adds an
ENOSPC/EMFILEpolling fallback to all three watchers, PR 3 suppresses auto-reload entirely during a deploy.Where to look
components/EntryHandler.ts:193-220— the newignoredcallback. The substring check is replaced with anchored regexes ((?:^|\/)…(?:\/|$)) so similar-named user paths aren't false-matched.relativePathderivation was simplified — the previous redundantstartsWith(directory + '/')thenstartsWith(directory)ternary collapsed into a single slice. Leaves leading/on inner paths and an empty string when the path is the component dir itself, which the regex anchors handle correctly.unitTests/components/EntryHandler.test.jscover each excluded pattern plus a prefix/suffix over-match negative case.Cross-model review notes
pnpm-debug.log(not.pnpm-debug.log) is the actual filename pnpm writes — fixed.npm-debug.log.txtandnpm-debug.log/would have been over-matched — fixed by appending(?:\/|$). Also suggested an explicit suffix-overmatch test case, added.Potential concerns to focus on
ignoredwhencwdis set. Verified by reading chokidar's_isIgnored→normalizeIgnored(chokidaresm/index.js:110,633): function matchers pass through unchanged, and the upstream caller resolves to absolute viagetAbsolutePath. The existingnode_modulesfilter (which depends on this assumption) already works, so the behavior is established.npm-debug.logor.git/HEADwill no longer see them. No such plugin is known to exist; the watcher contract has always been "files matching your glob, minus implementation-defined noise."