i18next / i18next

i18next: learn once - translate everywhere
https://www.i18next.com
MIT License
7.69k stars 640 forks source link

Run eslint -> JavaScript heap out of memory #1883

Open ximex opened 1 year ago

ximex commented 1 year ago

🐛 Bug Report

If i run eslint i got this error since i18next v2.4.4. It comes from the rules "@typescript-eslint/no-misused-promises". I don't know if it is a @typescript-eslint or i18next bug. With v2.4.3 or before there are no problems.

> eslint ./

<--- Last few GCs --->

[12938:0x67d8210]    77956 ms: Mark-sweep (reduce) 1881.7 (1921.3) -> 1881.7 (1914.3) MB, 950.8 / 0.0 ms  (average mu = 0.564, current mu = 0.000) last resort; GC in old space requested
[12938:0x67d8210]    78893 ms: Mark-sweep (reduce) 1881.7 (1914.3) -> 1881.7 (1914.3) MB, 936.6 / 0.0 ms  (average mu = 0.379, current mu = 0.000) last resort; GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 0xb6e500 node::Abort() [node]
 2: 0xa7e632  [node]
 3: 0xd47f20 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0xd482c7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0xf137bf v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 6: 0xef3b80 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [node]
 7: 0xeeb14c v8::internal::FactoryBase<v8::internal::Factory>::AllocateRawArray(int, v8::internal::AllocationType) [node]
 8: 0xeeb2c5 v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller(v8::internal::Handle<v8::internal::Map>, int, v8::internal::Handle<v8::internal::Oddball>, v8::internal::AllocationType) [node]
 9: 0x11a493e v8::internal::MaybeHandle<v8::internal::OrderedHashMap> v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Allocate<v8::internal::Isolate>(v8::internal::Isolate*, int, v8::internal::AllocationType) [node]
10: 0x11a49f3 v8::internal::MaybeHandle<v8::internal::OrderedHashMap> v8::internal::OrderedHashTable<v8::internal::OrderedHashMap, 2>::Rehash<v8::internal::Isolate>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::OrderedHashMap>, int) [node]
11: 0x12ae96d v8::internal::Runtime_MapGrow(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x16e99f9  [node]
Aborted (core dumped)

To Reproduce

run eslint with rule "@typescript-eslint/no-misused-promises"

Expected behavior

That eslint runs through again

Your Environment

adrai commented 1 year ago

Can you please provide a minimal repository so we can reproduce this?

esetnik commented 1 year ago

I have confirmed the same issue in my project. Both v2.4.4 and v2.4.5 are affected.

jansedlon commented 1 year ago

Mine as well. When I run tsc with version 2.4.5 it crashes with the same error. It runs out of memory. Version 22.4.3 is the latest that works fine

esetnik commented 1 year ago

@adrai Same issue on v22.4.6

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

esetnik commented 1 year ago

Mark as not stale

esetnik commented 1 year ago

Still happening on v22.4.8

esetnik commented 1 year ago

Is this related to #1857?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

ximex commented 1 year ago

Mark as not stale

CreativeTechGuy commented 1 year ago

Minimal repo is now available here: #1901 @adrai. Hope this helps!

esetnik commented 1 year ago

I can confirm this is still occurring on v22.4.10

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

adrai commented 1 year ago

Please try with i18next v23.0.1 and react-i18next v13.0.0

esetnik commented 1 year ago

@adrai see https://github.com/i18next/i18next/issues/1972

pedrodurek commented 1 year ago

Hey @esetnik, we really need a reproducible example to investigate what should be the root cause 😢

esetnik commented 1 year ago

@pedrodurek sorry I have been trying to build a reproducible example but I cannot even get the example I put together to typecheck cleanly due to https://github.com/i18next/react-i18next/issues/1647 so I cannot provide a full example which demonstrates this issue.

adrai commented 1 year ago

Can you try if it's better with v23.3.0?

esetnik commented 1 year ago

Unfortunately no it's the same issue

adrai commented 1 year ago

Unfortunately no it's the same issue

@ximex and for you?

ximex commented 1 year ago
"i18next": "^23.4.2",
"react-i18next": "^13.0.3",

with this versions tested it looks like it is fixed.

adrai commented 1 year ago

So can we close this issue?

ximex commented 1 year ago

For me it is fixed. @esetnik also for you?

esetnik commented 1 year ago

I am still experiencing the issue and stuck on the older version until it is resolved. The last version that is able to lint my project without Allocation failed - JavaScript heap out of memory errors is:

i18next@22.4.3
react-i18next@12.3.1
omoifodarling commented 1 year ago

Yes you may

Sent from my iPhone 14 Pro Max 📲

On Aug 7, 2023, at 12:29 PM, Adriano Raiano @.***> wrote:



So can we close this issue?

— Reply to this email directly, view it on GitHubhttps://github.com/i18next/i18next/issues/1883#issuecomment-1668219515, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADZWDNIBU45QD23UHLWERO3XUEJXBANCNFSM6AAAAAAS5J7FBE. You are receiving this because you commented.Message ID: @.***>

adrai commented 1 year ago

@esetnik seems @pedrodurek is still waiting for an example by you?

esetnik commented 1 year ago

@ximex can you tell me which versions of @typescript-eslint you are using and provide me with your eslint config? I'd like to try to reproduce it using your configs since they are working for you.

ximex commented 1 year ago

it worked with 5.62.0 and also with 6.3.0

the config (@typescript-eslint@^6.3.0) without the huge list of rules:

module.exports = {
    "root": true,
    "env": {
        "browser": true,
        "node": true,
        "commonjs": true,
        "es2023": true,
        "jest/globals": true,
    },
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 2023,
        "sourceType": "module",
        "ecmaFeatures": {
            // "impliedStrict": true,
            "jsx": true,
        },
        "project": true,
        "extraFileExtensions": [".json"],
    },
    "settings": {
        "react": {
            "version": "detect",
        },
        // "jest": {
        //  "version": "29",
        // },
    },
    "plugins": [
        "@typescript-eslint",
        "react",
        "react-hooks",
        "i18next",
        "jest",
        "jest-extended",
    ],
    "extends": [
        "eslint:recommended",
        "plugin:node/recommended",
        "plugin:react/jsx-runtime",
    ],
    "rules": {
        ...
    },
};
esetnik commented 1 year ago

@ximex do you have @typescript-eslint/no-misused-promises enabled?

ximex commented 1 year ago

yes

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

esetnik commented 1 year ago

please mark as not stale

bencerf commented 9 months ago
"i18next": "^23.4.2",
"react-i18next": "^13.0.3",

with this versions tested it looks like it is fixed.

I confirm what @ximex said, with theses version, i don't have any more JS heap out of memory error !! :clap: :raised_hands: EDIT: after developping more, I got the JS heap out of memory error... :sob:

We're just upgrading from v22 to @latest v23 (see below) but TSC just die after making any changes and waiting 15sec... image

Here our short listed package.json that failed :

"dependencies": {
  // ...
  "i18next": "^23.7.7",
  "i18next-chained-backend": "^4.6.2",
  "i18next-http-backend": "^2.4.2",
  "i18next-parser": "^8.9.0",
  "i18next-resources-to-backend": "^1.2.0",
  // ...
  "react-i18next": "^13.5.0"
},

Fyi, our devDependencies:


"devDependencies": {
  // ...
  "@typescript-eslint/eslint-plugin": "^5.60.1",
  "@typescript-eslint/parser": "^5.60.1",
  // ...
  "eslint": "^8.43.0",
  "eslint-config-prettier": "^8.8.0",
  "eslint-config-standard": "^17.1.0",
  "eslint-plugin-import": "^2.27.5",
  "eslint-plugin-no-restricted-imports": "^0.0.0",
  "eslint-plugin-playwright": "^0.15.3",
  "eslint-plugin-prettier": "^4.2.1",
  "eslint-plugin-react": "^7.32.2",
  "eslint-plugin-react-hooks": "^4.6.0",
  "eslint-plugin-simple-import-sort": "^10.0.0",
  "eslint-plugin-unused-imports": "^2.0.0"
  // ...
},

I don't really know how I could provide a reproducible example repository for this sort of bug, sorry...

bencerf commented 9 months ago

Sorry about my previous comment, we finally managed to fix our Error: Worker terminated due to reaching memory limit: JS heap out of memory by increasing virtual memory (NODE_OPTIONS) of node with 8Gb (as explained here).

Working for us with @latest i18next & react-i18next :

    "dependencies": {
      "i18next": "^23.7.7",
      "i18next-chained-backend": "^4.6.2",
      "i18next-http-backend": "^2.4.2",
      "i18next-parser": "^8.9.0",
      "i18next-resources-to-backend": "^1.2.0",
      // ...
      "react-i18next": "^13.5.0"
    },

Here our script using vite :

  "scripts": {
    "start": "export NODE_OPTIONS=--max-old-space-size=8192 && vite",
  }