qmd update: hook failure kills entire process, silently skipping every later collection
Summary
qmd update's per-collection update: hook (a shell command run before scanning, e.g. for git pull) has two bugs in updateCollections() (v2.5.3, dist/cli/qmd.js):
- It spawns the hook via
nodeSpawn("bash", ["-c", yamlCol.update], ...)— a bare"bash"command name relies on PATH resolution in whatever environment invoked theqmdprocess. In my environment (a Claude Code session's Bash tool), this consistently failed withError: spawn bash ENOENT, even thoughbashresolves fine viawhich bashin the same shell that invokedqmd. - Much more damaging: on any hook failure (non-zero exit, or the spawn itself erroring), the code calls
process.exit(exitCode)/process.exit(1)from inside the per-collection loop. This kills the entireqmd updateprocess outright — every collection after the failing one silently never gets scanned. In my case this meant aknowledgecollection went 55+ days without being re-indexed, because an unrelateddocscollection's git-pull hook was failing on every run and no one noticed (the whole process died with no indication which collections were affected or that later ones were skipped).
Steps to reproduce
- Configure two collections in
~/.config/qmd/index.yml; give the first one anupdate:hook that fails (e.g. a nonexistent binary, or hit the PATH issue above). - Run
qmd update. - Observe: the first collection's hook failure kills the process; the second collection is never scanned, with no explicit "N collections skipped" summary.
Expected: a hook failure is logged clearly, and the run continues to scan every other collection regardless. Actual: the whole run aborts silently partway through.
Suggested fix
Both fixes are small and I've verified them locally:
// 1. Avoid PATH-resolution issues entirely:
const proc = nodeSpawn("/bin/bash", ["-c", yamlCol.update], { ... });
// 2. Don't kill the whole process on one collection's hook failure:
// (inside the per-collection loop, replace both process.exit() calls)
if (exitCode !== 0) {
console.log(`✗ Update command failed with exit code ${exitCode}`);
hookFailed = true; // instead of process.exit(exitCode)
}
// ...
catch (err) {
console.log(`✗ Update command failed: ${err}`);
hookFailed = true; // instead of process.exit(1)
}
if (hookFailed) {
console.log(` Continuing without running this collection's update hook.`);
}Verified locally (patched the installed package): a deliberately-broken hook on one collection now logs the failure and the run still successfully scans every other collection; the original bash ENOENT also disappeared once hardcoded to /bin/bash.
Happy to open a PR with this diff if useful — wanted to raise the issue first in case there's a reason for the current behavior I'm not seeing (e.g. intentionally treating a hook failure as fatal for that collection specifically, though even then it shouldn't take down collections it hasn't reached yet).
Source: tobi/qmd