fix: log hook and dispatch errors instead of exiting - #15
Conversation
Any hook run error (typo in command path, resource exhaustion...) or failure to canonicalize an event's folder path propagated to main and killed the daemon on the first triggered event. Log these errors and keep the event loop running. Event dispatch is extracted into a function so the behavior is testable. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Good catch, on both counts: the unresolvable folder path is the worst one, since with the provided systemd unit it becomes a crash loop that also drops the in-memory event cursor, silently losing events for healthy folders on each restart. I fixed it differently in 3adfbec, on top of the reworks that conflicted with this PR: spawn failures are logged inside One deliberate difference: a reaper channel send failure stays fatal, where If you have more fixes coming please say so, otherwise I will tag a new release in a few days. |
|
Nothing blocking a release from my side — the reworks look good, and the crash-loop-drops-the-cursor consequence you spotted is nastier than what I reported. Two minor notes, take them or leave them:
Thanks for the quick turnaround on all of these. 🤖 Generated with Claude Code |
|
On the repeated error: I'd rather not special-case this. A Syncthing instance reporting paths that don't exist on the host stfed runs on is a Docker deployment mismatch, to be fixed on that side. A once-per-folder dedup would also quiet the case where a hooked folder loses its mount mid-run, which is exactly when a repeating error is the signal you want. On the API key: with the pinned ureq it is not logged at debug level — ureq logs headers through an allowlist, so |
Every
hook::run(...)?and foldertry_into()?in main's dispatch propagates tomain()and exits the daemon: a typo in a hook command path kills stfed on the first triggered event, and a Syncthing folder whose path doesn't resolve locally (e.g. Syncthing running in Docker reporting container paths) kills it on the first event for that folder — even if no hook references it.Log hook run errors and keep dispatching; folder resolution errors are logged by the caller and no longer stop the event loop. Dispatch is extracted from
main()intodispatch_eventso the behavior is testable.Red-green test:
failing_hook_does_not_interrupt_dispatch(a failing hook must not prevent the following hook from running — on master the equivalent flow returns an error that exits the daemon), plusunresolvable_folder_path_is_an_errordocumenting that a bad folder path is a recoverable error.Follow-up ready once this lands: warn once per unresolvable folder instead of logging an error on every event for it.
🤖 Generated with Claude Code