betterer
betterer copied to clipboard
OOM in a Nix environment
Describe the bug A coworker (@loafofpiecrust) ran into an OOM error running the betterer cli in a nix environment. They said they suspected that it would be due to some kind of (maybe transitive?) native dependency. It happened even with '--silent', so I don't think it could be ink's fault.
To Reproduce The command in our npm script is 'betterer --config betterer/betterer.ts --results betterer/betterer.results'. I might be able to share the exact files privately, but doubt that I could post them here. The config is 'strict: true, incremental: false' extending our real tsconfig. The results file is about 1000 lines.
Expected behavior The same betterer check failure between a nix and a brew environment.
Versions:
-
OS: MacOS with Nix package management
-
Betterer Version "@betterer/cli": "^5.1.6" "@betterer/typescript": "^5.1.7"
-
Node Version 16.13.1
Used to get the same due to betterer running eslint. We have a huge ruleset and huge code base and it always broke. We run lint-staged as a precommit hook which in turn runs betterer with our eslint rules.
Using cross-env with the max old space size flag does the trick for us.
npx cross-env NODE_OPTIONS="--max_old_space_size=8000" lint-staged
Yeah, I've definitely seen this, and I think it has something to do with running the tests in a Node worker thread. I'm not exactly sure how memory is shared between workers. I'll dig in a bit more and see what I can improve.
Used to get the same due to betterer running eslint. We have a huge ruleset and huge code base and it always broke. We run lint-staged as a precommit hook which in turn runs betterer with our eslint rules.
Using cross-env with the max old space size flag does the trick for us.
npx cross-env NODE_OPTIONS="--max_old_space_size=8000" lint-staged
I also have this issue too. I run betterer with --workers=false to mitigate this problem.
I just want to chime in here. I'm working on a massive Angular project (one of the largest the Angular team knows of) and when I use betterer and limit to one file, it still runs out of memory.
my better script looks like:
"betterer": "cross-env NODE_OPTIONS='--max_old_space_size=64000' betterer './apps/client/**/*.ts' --workers=false"
and my betterer.ts file looks like
import { eslint } from '@betterer/eslint';
export default {
'standard-rules': () => eslint({
'max-depth': ['error', { max: 2 }]
}).include('./**/*.ts'),
};
If I leave off the .include() then the process completes but doesn't seem to process any files.