-
Notifications
You must be signed in to change notification settings - Fork 2
Description
This ticket is relative to this issue but it has different behaviour and causes memory leak.

I am currently using a MacBook Pro 14 inch with M1 Pro with 16G Ram, OS version is 14.1
If the analysis process encounters an error, such as the one mentioned, there may not be an apparent issue. However, problems may arise when committing a large number of files simultaneously, like during a 300-file refactoring. In such cases, the process might exhaust the computer's memory and continually create new Dart processes in the background. Upon investigating the code, I observed that the process fails to terminate in the event of an error [will not kill the process](https://github.com/hyiso/lint_staged/blob/main/lib/s

rc/run.dart).
What I suggest is that, add the kill process code on error handling as the Flutter does not have feature of Future.allSettled()
if (result.stderr.toString().trim().isNotEmpty) {
messsages.add(red(result.stderr.toString().trim()));
Process.killPid(result.pid); // Kill process here
}
if (result.stdout.toString().trim().isNotEmpty) {
messsages.add(result.stdout.toString().trim());
}
_verbose(messsages.join('\n'));
if (result.exitCode != 0) {
ctx.output.add(messsages.join('\n'));
ctx.errors.add(kTaskError);
Process.killPid(result.pid); // Kill process here
}As I'm uncertain about the business logic, this may not work as the message does not update. So it seems the issue could be attributed to the process not terminating properly, causing it to stay in the memory forever.