Closed tubbo closed 1 year ago
What does your ESLint config look like? And what does your code look like? ESLint doesn't go into ./node_modules by default, so we'll need more info.
@vkarpov15 I don't think we are trying to go into ./node_modules
, but here is my full .eslintrc.js:
const ERROR_IN_CI = process.env.CI ? 'error' : 'warn'
const path = require('path')
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
jest: true,
},
globals: {
fail: true, // false=not writable, true=writable
globalThis: false,
},
plugins: ['import', 'testing-library', 'jest-dom'],
extends: ['eslint:recommended', 'prettier'],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
'import/namespace': 'off',
'no-console': [ERROR_IN_CI, { allow: ['error'] }],
},
settings: {
react: {
version: 'detect',
},
},
overrides: [
// Scripts can have console statements
{
files: ['api/scripts/**/*'],
rules: {
'no-console': 'off',
},
},
// React Apps
{
files: ['web/**/*', 'cms/**/*'],
env: {},
parser: '@babel/eslint-parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
sourceType: 'module',
babelOptions: {
configFile: './web/.babelrc',
},
},
extends: ['plugin:jsx-a11y/recommended'],
plugins: ['prefer-arrow'],
rules: {
'prefer-arrow/prefer-arrow-functions': 'error',
'react/prop-types': 'off',
'import/no-unresolved': [2, { ignore: ['^(all|part):'] }], // ignore Sanity part imports
'jsx-a11y/anchor-is-valid': 'off', // temp for now, until better way to exclude Next Links
'jsx-a11y/no-static-element-interactions': 'off', // temp for now, until better way to exclude Next Links
},
globals: {
twttr: true,
},
},
{
files: ['**/*.ts?(x)'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
tsconfigRootDir: __dirname,
warnOnUnsupportedTypescriptVersion: true,
},
plugins: ['@typescript-eslint', 'typescript-sort-keys'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:typescript-sort-keys/recommended',
],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_' },
],
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off', // to be turned back on shortly
'@typescript-eslint/no-unsafe-call': 'off', // to be turned back on shortly
'@typescript-eslint/no-unsafe-return': 'off', // to be turned back on shortly
'@typescript-eslint/no-unsafe-assignment': 'off', // to be turned back on shortly
'@typescript-eslint/no-floating-promises': 'off', // to be turned back on shortly
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-nocheck': 'allow-with-description',
},
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-extra-semi': 'off',
// TODO: We can't turn this off until we get rid of Mongoose.
'@typescript-eslint/no-unsafe-argument': 'off',
},
},
{
files: ['web/**/*.ts?(x)'],
extends: ['next'],
parserOptions: {
project: ['web/tsconfig.json'],
},
rules: {
// TODO: The following are good rules to have but we
// break them too often. Go through the codebase and fix
// all these instances of explicit any or ignore the rule
// on specific lines.
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'react-hooks/exhaustive-deps': 'off',
'@next/next/no-html-link-for-pages': [
'error',
path.join(process.cwd(), 'src', 'pages'),
],
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
project: 'web/tsconfig.json',
},
},
},
},
{
files: [
'web/**/__tests__/**/*.[jt]s?(x)',
'web/**/?(*.)+(spec|test).[jt]s?(x)',
],
extends: ['plugin:testing-library/react', 'plugin:jest-dom/recommended'],
},
// API
{
files: ['api/**/*'],
globals: {
fail: true,
},
rules: {
'no-unused-vars': 'off',
'multiline-ternary': 'off',
'prefer-regex-literals': 'off',
},
parserOptions: {
project: ['api/tsconfig.json'],
},
},
// JSON Configuration Files
{
extends: ['plugin:json/recommended-with-comments'],
files: ['**/*.json'],
plugins: ['json'],
},
{
files: ['component-library/**/*.ts?(x)'],
parserOptions: {
project: ['component-library/tsconfig.eslint.json'],
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
],
}
we also have an .eslintignore file at the root of our repo:
!**/.eslintrc*
*node_modules*
*.svg
*.ico
.gitignore
*.md
*.log
*yarn.lock
.yarn
web/!.storybook
web/storybook-static
web/tmp
web/src/models.tsx
web/src/operations.ts
api/src/http/graphql/generated*
api/dist
web/.next
cms/dist/**
I'm going to try to see if ESLint is indeed encountering vendored dependencies or something by setting DEBUG="eslint:file-enumerator"
in CI. From what I can tell this isn't happening locally, so maybe it's a GitHub Actions thing..
I can confirm that we are not iterating over node_modules/
directories at all in my application.
[...]
2022-01-13T22:00:11.307Z eslint:file-enumerator Enter the directory: /home/runner/work/lobby/lobby/web/config
2022-01-13T22:00:11.310Z eslint:file-enumerator Yield: redirects.json
2022-01-13T22:00:11.518Z eslint:file-enumerator Leave the directory: /home/runner/work/lobby/lobby/web/config
2022-01-13T22:00:11.541Z eslint:file-enumerator Yield: jest-setup.ts
<--- Last few GCs --->
[2120:0x5566a20] 92940 ms: Mark-sweep 2042.4 (2064.6) -> 2039.5 (2066.4) MB, 2303.6 / 0.0 ms (average mu = 0.076, current mu = 0.006) allocation failure scavenge might not succeed
[2120:0x5566a20] 95263 ms: Mark-sweep (reduce) 2047.8 (2066.6) -> 2042.7 (2068.6) MB, 2254.2 / 0.0 ms (+ 0.1 ms in 126 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2323 ms) (average mu = 0.053, current mu = 0.029)
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa389b0 node::Abort() [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
2: 0x96e0af node::FatalError(char const*, char const*) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
5: 0xd73fd5 [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
6: 0xd74b5f [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
7: 0xd8299b v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
8: 0xd8655c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
9: 0xd54c3b v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
10: 0x109d21f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
11: 0x1446379 [/opt/hostedtoolcache/node/14.18.2/x64/bin/node]
Aborted (core dumped)
error Command failed with exit code 134.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
ERROR: "lint:analysis" exited with 134.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.
I looked through the whole backlog of eslint:file-enumerator
debug messages, and couldn't find a single instance of it diving into a node_modules/
dir of any kind.
I'm pretty stumped, honestly. Might try and bisect the past versions of Mongoose, because at this point every time Renovate asks us to upgrade the library we run into this same issue and can't proceed.
Having the exact same problem w/ tsc
and mongoose breaking the typescript build via OOM.
node --max-old-space-size=8192 ./node_modules/.bin/tsc --diagnostics --project tsconfig.production.json
<--- Last few GCs --->
[24997:0x7f7f29100000] 445689 ms: Mark-sweep 8091.8 (8237.4) -> 8087.9 (8237.9) MB, 29434.8 / 0.0 ms (average mu = 0.073, current mu = 0.001) allocation failure scavenge might not succeed
[24997:0x7f7f29100000] 479110 ms: Mark-sweep 8092.2 (8237.9) -> 8088.6 (8238.6) MB, 33364.2 / 0.0 ms (average mu = 0.032, current mu = 0.002) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x10e13c815 node::Abort() (.cold.1) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
2: 0x10ce3baa9 node::Abort() [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
3: 0x10ce3bc1f node::OnFatalError(char const*, char const*) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
4: 0x10cfbc877 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
5: 0x10cfbc813 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
6: 0x10d15dc65 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
7: 0x10d161cad v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
8: 0x10d15e58d v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
9: 0x10d15baad v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
10: 0x10d168de0 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
11: 0x10d168e61 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
12: 0x10d135fb7 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
13: 0x10d4eb89e v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
14: 0x10d8952b9 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/james/.nvm/versions/node/v16.13.1/bin/node]
15: 0x1155613fa
thank you @James1x0 i was hoping i wasn't just insane! we're using TypeScript as well. this code exists within a monorepo, but the API part of the monorepo is where all the mongoose code is located, and also the part of the app that's keeping us on an older version of typescript, v4.1.3 to be exact. not sure if that has anything to do with it..
So the issue might be with TypeScript, not ESLint. What does your tsconfig look like? You might try setting the skipLibCheck option and see if that helps.
@vkarpov15 I have skipLibCheck
set to true
in my TSConfig (posted in the OP)
@vkarpov15 Also have skipLibCheck
true
. Can confirm after running "--generateTrace" with typescript build, the build slows significantly and specifically on our model declaration files until it comes to a halt running out of memory. Still in the middle of profiling the build. Can confirm that mongoose@6.1.7
resolves this issue, but hoping to delay the major upgrade.
We're trying to deal with the major version upgrade to fix these issues but I have to be honest, I'm not really looking forward to it. Lots of work and risk on our part just because Mongoose doesn't play nice with TypeScript?
We took a quick look, but there's no way we're realistically going to repro this. tsconfig.json
isn't even valid JSON, ESLint config is invalid, can't even get the full setup to run after installing what seems like half of npm. Without a working repro script, there's no way we're going to be able to figure this out, so if you're still having this issue please open a new issue and follow the issue template.
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Crashes while running ESLint due to OOM:
If the current behavior is a bug, please provide the steps to reproduce.
TSConfig:
What is the expected behavior?
My ESLint task doesn't fail due to OOM
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
I'd love to use the latest version of Mongoose but upgrading it at all tends to break.