Skip to content
Latchkey

Node.js "nodemon" Watcher Hangs the CI Job

nodemon is a long-running file watcher meant for development. Started in CI, it never exits on its own, so the job hangs until it times out, or fails with ENOSPC when it runs out of watches.

What this error means

A CI step that runs nodemon (often via a dev script) hangs and is eventually killed by the job timeout, or fails immediately with an inotify ENOSPC error.

node
[nodemon] starting `node src/index.js`
[nodemon] watching path(s): **/*
# job hangs here until the CI timeout fires

Common causes

A watch command ran in CI

A dev/watch script that uses nodemon was used in a CI step. Watchers do not terminate, so the step never completes.

Watcher exhausts inotify watches

On a large tree, nodemon may also hit the file-watcher limit and fail with ENOSPC before it would otherwise hang.

How to fix it

Use the non-watch command in CI

Run the plain start/build/test command instead of the watch variant.

workflow
# CI runs this, not "nodemon src/index.js"
node src/index.js
# or for tests
npm test

If a server is needed, background it and gate on readiness

Start the server in the background, wait for it, run the task, then let the job exit.

  1. Start the server with node ... & (no watcher).
  2. Wait on its port with wait-on.
  3. Run the dependent task, then the job exits.

How to prevent it

  • Never run watch commands (nodemon) in CI steps.
  • Keep dev and start/ci scripts separate.
  • Background and readiness-gate any server CI needs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →