Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delayed FileWatching: Maybe a OutOfProcessNodeJSServiceOptions property? #179

Open
Zettersten opened this issue Sep 29, 2023 · 2 comments
Open

Comments

@Zettersten
Copy link

Greetings,

I have a node application that uses rollup.js to produce esm modules for my dotnet program.

Rollup has a watch feature that executes the compilation of a node project when code changes.

In my case, rollup delete old files and ands new ones (using file chunk hashes - so their different each compilation).

The deleting of old files and writing of new files causes the FileWatcher in OutOfProcessNodeJSService to go crazy for bit.

It rapidly tries to kill processes and spin up new ones.

Can we add a delay or throttle option to the FileWatcher?

@JeremyTCD
Copy link
Member

We could do with something like webpack's aggregateTimeout option: "Add a delay before rebuilding once the first file changed. This allows webpack to aggregate any other changes made during this time period into one rebuild. Pass a value in milliseconds". Could also consider debouncing.

Would you like to have a go at it? This is the relevant method:

internal virtual void FileChangedHandler()
{
if (_debugLoggingEnabled)
{
Logger.LogDebug(string.Format(Strings.LogDebug_FileChangedHandlerInvokedForProcess, _nodeJSProcess?.SafeID));
}
#pragma warning disable CS4014
// No need to await
//
// Note that we need to reconnect even if we've just connected so that the changed file is loaded.
MoveToNewProcessAsync(true);
#pragma warning restore CS4014
}

@Zettersten
Copy link
Author

This is what I came up with:

#182

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants