GetStream / stream-chat-react-native

💬 React-Native Chat SDK ➜ Stream Chat. Includes a tutorial on building your own chat app experience using React-Native, React-Navigation and Stream
https://getstream.io/chat/sdk/react-native/
Other
976 stars 325 forks source link

" JavaScript heap out of memory" when installing stream-chat-expo #1384

Closed RRaideRR closed 2 years ago

RRaideRR commented 2 years ago

Describe the bug I'm getting an "JavaScript heap out of memory" error when trying to install stream-chat-expo. A colleague of mine also experiences that issue with our current project. However, when I start a fresh project, it works as expected.

Right now I don't know what the cause of the issue is and how I can further investigate on it. So I welcome any help or hints :-).

Dev environment info (please complete/provide the following information): My current package.json

{
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "test": "jest"
  },
  "dependencies": {
    "@expo-google-fonts/playfair-display": "^0.1.0",
    "@expo-google-fonts/poppins": "^0.1.0",
    "@expo/vector-icons": "^12.0.0",
    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-async-storage/async-storage": "~1.15.0",
    "@react-native-community/datetimepicker": "4.0.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "7.1.3",
    "@react-native-community/slider": "4.1.12",
    "@react-native-picker/picker": "2.2.1",
    "@react-navigation/bottom-tabs": "^6.0.9",
    "@react-navigation/core": "^6.1.0",
    "@react-navigation/material-top-tabs": "^6.0.6",
    "@react-navigation/native": "^6.0.6",
    "@react-navigation/native-stack": "^6.2.5",
    "@react-navigation/routers": "^6.1.0",
    "@react-navigation/stack": "^6.0.11",
    "@reduxjs/toolkit": "^1.6.0",
    "@sentry/react-native": "^3.2.13",
    "axios": "^0.21.1",
    "date-fns": "^2.19.0",
    "expo": "^44.0.0",
    "expo-application": "~4.0.1",
    "expo-av": "~10.2.0",
    "expo-blur": "~11.0.0",
    "expo-constants": "~13.0.1",
    "expo-dev-client": "~0.8.5",
    "expo-device": "~4.1.0",
    "expo-file-system": "~13.1.4",
    "expo-firebase-analytics": "~6.0.0",
    "expo-firebase-core": "~4.1.0",
    "expo-firebase-recaptcha": "~2.1.0",
    "expo-font": "~10.0.4",
    "expo-image-manipulator": "~10.2.0",
    "expo-image-picker": "~12.0.1",
    "expo-intent-launcher": "~10.1.3",
    "expo-keep-awake": "~10.0.1",
    "expo-linear-gradient": "~11.0.3",
    "expo-linking": "~3.0.0",
    "expo-location": "~14.0.1",
    "expo-media-library": "~14.0.0",
    "expo-notifications": "~0.14.0",
    "expo-splash-screen": "~0.14.1",
    "expo-status-bar": "~1.2.0",
    "expo-system-ui": "~1.1.0",
    "expo-tracking-transparency": "~2.1.0",
    "expo-updates": "~0.11.7",
    "firebase": "8.2.3",
    "google-libphonenumber": "^3.2.26",
    "i18next": "^21.6.3",
    "i18next-chained-backend": "^3.0.2",
    "i18next-resources-to-backend": "^1.0.0",
    "jest-expo": "^44.0.1",
    "lottie-react-native": "5.0.1",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-i18next": "^11.15.1",
    "react-native": "0.64.3",
    "react-native-app-link": "^1.0.1",
    "react-native-copilot": "^2.5.1",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-elements": "^3.1.0",
    "react-native-emoji": "^1.8.0",
    "react-native-fbsdk-next": "^7.3.3",
    "react-native-gesture-handler": "~2.1.0",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-iphone-x-helper": "^1.3.1",
    "react-native-pager-view": "5.4.9",
    "react-native-phrase-sdk": "^1.0.0",
    "react-native-progress": "^4.1.2",
    "react-native-reanimated": "~2.3.1",
    "react-native-redash": "^16.0.8",
    "react-native-root-toast": "^3.3.0",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-svg": "12.1.1",
    "react-native-tab-view": "^3.1.1",
    "react-native-web": "0.17.1",
    "react-native-webview": "11.15.0",
    "react-redux": "^7.2.2",
    "redux": "^4.1.0",
    "redux-thunk": "^2.3.0",
    "rgb-hex": "^4.0.0",
    "sentry-expo": "^4.0.0",
    "styled-components": "^5.2.0",
    "tinycolor2": "^1.4.2",
    "toggle-switch-react-native": "^2.3.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@react-native-community/eslint-config": "^3.0.1",
    "@testing-library/react-hooks": "^7.0.1",
    "@types/enzyme": "3.10.11",
    "@types/google-libphonenumber": "^7.4.23",
    "@types/jest": "^27.4.1",
    "@types/lodash": "^4.14.178",
    "@types/react": "~17.0.21",
    "@types/react-native": "~0.64.12",
    "@types/react-redux": "^7.1.16",
    "@types/react-test-renderer": "^17.0.1",
    "@types/redux": "^3.6.0",
    "@typescript-eslint/eslint-plugin": "^4.14.2",
    "@typescript-eslint/parser": "^4.19.0",
    "babel-plugin-module-resolver": "^4.1.0",
    "babel-preset-expo": "9.0.1",
    "enzyme": "^3.11.0",
    "enzyme-adapter-react-16": "^1.15.6",
    "eslint": "^7.11.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-config-airbnb-typescript": "^12.0.0",
    "eslint-plugin-import": "^2.25.4",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.22.0",
    "eslint-plugin-react-hooks": "^4.2.0",
    "jest": "^26.6.3",
    "jest-expo-enzyme": "^1.2.5",
    "jest-react-hooks-shallow": "^1.5.1",
    "prettier": "^2.5.1",
    "react-devtools-core": "^4.14.0",
    "react-native-dotenv": "^2.5.3",
    "react-test-renderer": "^17.0.2",
    "typescript": "~4.3.5"
  },
  "resolutions": {
    "jest-environment-jsdom": "27.4.6",
    "react-devtools-core": "4.14.0"
  },
  "private": true,
  "version": "1.5.0",
  "name": "my-top-secret-app"
}

Additional context Full stacktrace from expo install stream-chat-expo:

expo install stream-chat-expo              
Installing 1 other package using Yarn.
> yarn add stream-chat-expo
yarn add v1.22.18
[1/4] 🔍  Resolving packages...
warning Resolution field "jest-environment-jsdom@27.4.6" is incompatible with requested version "jest-environment-jsdom@^26.6.2"
warning Resolution field "jest-environment-jsdom@27.4.6" is incompatible with requested version "jest-environment-jsdom@^24.0.0"
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...

<--- Last few GCs --->

[15444:0x140008000]    74298 ms: Mark-sweep (reduce) 4076.5 (4102.7) -> 4075.9 (4104.0) MB, 1070.7 / 0.0 ms  (average mu = 0.138, current mu = 0.002) allocation failure scavenge might not succeed
[15444:0x140008000]    77549 ms: Mark-sweep (reduce) 4077.0 (4106.0) -> 4076.4 (4106.7) MB, 3247.9 / 0.0 ms  (average mu = 0.038, current mu = 0.001) allocation failure scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - JavaScript heap out of memory
 1: 0x1000b9028 node::Abort() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 2: 0x1000b91a8 node::OnFatalError(char const*, char const*) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 3: 0x1001bd08c v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 4: 0x1001bd020 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 5: 0x1002f8d44 v8::internal::Heap::CollectionBarrier::Wait() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 6: 0x10032ef34 v8::internal::EvacuateVisitorBase::TryEvacuateObject(v8::internal::AllocationSpace, v8::internal::HeapObject, int, v8::internal::HeapObject*) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 7: 0x10031fb64 void v8::internal::LiveObjectVisitor::VisitBlackObjectsNoFail<v8::internal::EvacuateNewSpaceVisitor, v8::internal::MajorNonAtomicMarkingState>(v8::internal::MemoryChunk*, v8::internal::MajorNonAtomicMarkingState*, v8::internal::EvacuateNewSpaceVisitor*, v8::internal::LiveObjectVisitor::IterationMode) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 8: 0x10031f820 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, long*) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
 9: 0x10031f578 v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
10: 0x100332108 v8::internal::PageEvacuationTask::ProcessItems() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
11: 0x10033208c v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
12: 0x10030aea4 v8::internal::ItemParallelJob::Task::RunInternal() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
13: 0x10030b1ec v8::internal::ItemParallelJob::Run() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
14: 0x100320d70 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::MarkCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
15: 0x100320b9c v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
16: 0x100315a94 v8::internal::MarkCompactCollector::Evacuate() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
17: 0x100313e38 v8::internal::MarkCompactCollector::CollectGarbage() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
18: 0x1002f9204 v8::internal::Heap::MarkCompact() [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
19: 0x1002f75ac v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
20: 0x1002f5d94 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
21: 0x1002fed4c v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
22: 0x1002fedb8 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
23: 0x1002dda20 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
24: 0x10054db40 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
25: 0x1007b44ec Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
26: 0x1007c8f3c Builtins_ArrayPrototypeJoin [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
27: 0x1069a5638 
28: 0x106988dfc 
29: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
30: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
31: 0x100743c04 Builtins_ArgumentsAdaptorTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
32: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
33: 0x10077b57c Builtins_GeneratorPrototypeNext [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
34: 0x1069d3178 
35: 0x1069cda9c 
36: 0x100743c04 Builtins_ArgumentsAdaptorTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
37: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
38: 0x100743c04 Builtins_ArgumentsAdaptorTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
39: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
40: 0x10077b57c Builtins_GeneratorPrototypeNext [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
41: 0x1069d3178 
42: 0x1069cda9c 
43: 0x100743c04 Builtins_ArgumentsAdaptorTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
44: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
45: 0x100743c04 Builtins_ArgumentsAdaptorTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
46: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
47: 0x10077b57c Builtins_GeneratorPrototypeNext [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
48: 0x1069d23ac 
49: 0x10074ae34 Builtins_InterpreterEntryTrampoline [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
50: 0x1007f5adc Builtins_PromiseFulfillReactionJob [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
51: 0x10076b038 Builtins_RunMicrotasks [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
52: 0x1007485c8 Builtins_JSRunMicrotasksEntry [/opt/homebrew/Cellar/node@14/14.19.1/bin/node]
53: 0x140008000 
yarnpkg exited with signal: SIGABRT
Error: yarnpkg exited with signal: SIGABRT
    at ChildProcess.completionListener (/opt/homebrew/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:64:13)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Socket.<anonymous> (internal/child_process.js:443:11)
    at Socket.emit (events.js:400:28)
    at Pipe.<anonymous> (net.js:686:12)
    ...
    at spawnAsync (/opt/homebrew/lib/node_modules/expo-cli/node_modules/@expo/spawn-async/src/spawnAsync.ts:26:19)
    at YarnPackageManager._runAsync (/opt/homebrew/lib/node_modules/expo-cli/node_modules/@expo/package-manager/src/NodePackageManagers.ts:327:31)
    at YarnPackageManager.addWithParametersAsync (/opt/homebrew/lib/node_modules/expo-cli/node_modules/@expo/package-manager/src/NodePackageManagers.ts:272:16)
    at actionAsync (/opt/homebrew/lib/node_modules/expo-cli/src/commands/installAsync.ts:141:3)
santhoshvai commented 2 years ago

Hi,

Have you tried upgrading your node version? It would be very helpful if you can test this with node v16. Node v16 is the current LTS version.

GregAtFramework commented 2 years ago

I also experienced this problem. I believe I was using node v18 at the time.

Two options that worked for our project:

We ultimately went with the Yarn 3 option.

RRaideRR commented 2 years ago

Hi,

Have you tried upgrading your node version? It would be very helpful if you can test this with node v16. Node v16 is the current LTS version.

Hi @santhoshvai and thanks for giving me a helping hand here.

I updated node to version v16.15.0 and the issue is still persists.

RRaideRR commented 2 years ago

I also experienced this problem. I believe I was using node v18 at the time.

Two options that worked for our project:

  • Deleting yarn.lock (i.e. regenerating it)
  • Migrating to Yarn 3

We ultimately went with the Yarn 3 option.

Hi @GregAtFramework and thanks for your help!

I always had the impression that deleting yarn.lock is something that you should avoid. However, after deleting yarn.lock and running yarn install again, I was able to install stream-chat-expo. So that works! Thank you all!