Skip to content

macOS: Error starting FSEvents stream with many folders #190

@bpasero

Description

@bpasero

It seems there is a maximum of folders that can be watched. Anywhere from 500 paths, I see an false return from the call to FSEventStreamStart.

~/Desktop/parcel-test> node index.js
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

[Error: Error starting FSEvents stream]

Node.js v20.17.0

I was not able to figure out where this limit is coming from so far.

Code to reproduce:

const watcher = require('@parcel/watcher');
const path = require('path');
const fs = require('fs');

async function main() {

    for (let i = 0; i < 1000; i++) {
        const dirPath = path.join(process.cwd(), `folder_${i}`);
        fs.mkdirSync(dirPath, { recursive: true });
        const filePath = path.join(dirPath, `file_${i}.txt`);
        fs.writeFileSync(filePath, `This is file ${i}`);
    }

    for (let i = 0; i < 1000; i++) {
        const dirPath = path.join(process.cwd(), `folder_${i}`);
        let subscription = await watcher.subscribe(dirPath, (err, events) => {
            console.log(events);
        });
    }
}

main();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions