Skip to content

InotifyBackend hungs forever when inotify_init1 returns error #159

@amierzwicki

Description

@amierzwicki

Scenario

Sytem: linux (ubuntu 22.04)

When there are too many open inotify instances the parcel build will hung without any clue to why it's stuck.

Expected behavior

Parcel should throw clear exception - e.g. "There are too many open files, cannot initialize inotify instance"

Stretch goal

Suggest to user what are possible actions to fix it (e.g. writing higher value to /proc/sys/fs/inotify/max_user_instances).

Current behavior

When there are too many open inotify instances the inotify_init1 returns -1 with errno "Too many open files". This causes exception in InotifyBackend: https://github.com/parcel-bundler/watcher/blob/master/src/linux/InotifyBackend.cc#L25.

When this happens the Backend::run will block forever due to insufficient error handling (https://github.com/parcel-bundler/watcher/blob/master/src/Backend.cc#L103):

image

The fix will require a bit more than just calling mStartedSignal.notify() (error needs to be populated up the stack) - the above just highlights in what state the process ends up when this error happens.

Steps to reproduce

  1. Setup simple parcel project (package.json + src/index.js is sufficient)
  2. Set /proc/sys/fs/inotify/max_user_instances to some small value (e.g. 1)
  3. Run parcel build
  4. Parcel will hung forever:
> my-library@1.0.0 build
> parcel build

Workaround

Naturally the problem of too many inotify instances needs to be fixed (even when this bug will be resolved) - either by closing old processes in system or by increasing the limit echo 256 | sudo tee /proc/sys/fs/inotify/max_user_instances (default is often 128).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions