Question
Nodemon vs Node.js Process: Avoiding Duplicate Writes During Rapid Restarts
Tasadduq BurneyownerOwner · Founder
18K reputation · 29 Apr 2021, 22:52 UTC
59.4K views0
Nodemon vs Node.js Process: Duplicate Write Concerns
Goal
Determine how to configure Nodemon so that the Node.js application does not produce duplicate log entries when the process restarts immediately after a file change.
Constraints
Nodemon triggers a restart on every detected file event, and the underlying OS file‑watcher may emit multiple rapid events for a single edit. The application writes to a log file on each start, so overlapping writes can occur if the restart occurs before the previous write completes.
Open Questions
- Should Nodemon batch rapid file change events into a single restart, or should it restart for each event?
- What is the impact of the
--delayflag on the likelihood of duplicate writes in fast development cycles? - Can we rely on
--ignorepatterns to exclude files that frequently change during a restart, and how does that affect necessary restarts?