3

So I am trying to deploy my project to AWS LightSail instance

  1. I cloned my repo
  2. npm install
  3. npm start.
    And then the Allocation failed Error happened

Error:

<--- JS stacktrace --->

 FATAL ERROR: MarkCompactCollector: young object promotion failed Allocation failed - 
 JavaScript heap out of memory
 1: 0xa222f0 node::Abort() [node]
 2: 0x96411f node::FatalError(char const*, char const*) [node]
 3: 0xb97f1e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) 
 [node]
 4: 0xb98297 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char 
 const*, bool) [node]
 5: 0xd52fd5  [node]
 6:  0xd83bbe v8::internal::EvacuateNewSpaceVisitor::Visit(v8::internal::HeapObject, 
 int) [node]
 7: 0xd8fbf6 v8::internal::FullEvacuator::RawEvacuatePage(v8::internal::MemoryChunk*, 
 long*) [node]
 8: 0xd7bd8f v8::internal::Evacuator::EvacuatePage(v8::internal::MemoryChunk*) [node]
 9: 0xd7c008 v8::internal::PageEvacuationTask::RunInParallel(v8::internal::ItemParallelJob::Task::Runner) [node]
 10: 0xd6e8e9 v8::internal::ItemParallelJob::Run() [node]
 11: 0xd91b50 void v8::internal::MarkCompactCollectorBase::CreateAndExecuteEvacuationTasks<v8::internal::FullEvacuator, v8::internal::Mar
 kCompactCollector>(v8::internal::MarkCompactCollector*, v8::internal::ItemParallelJob*, v8::internal::MigrationObserver*, long) [node]
 12: 0xd923ec v8::internal::MarkCompactCollector::EvacuatePagesInParallel() [node]
 13: 0xd925b5 v8::internal::MarkCompactCollector::Evacuate() [node]
 14: 0xda45b1 v8::internal::MarkCompactCollector::CollectGarbage() [node]
 15: 0xd60878 v8::internal::Heap::MarkCompact() [node]
 16: 0xd62368 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,           v8::internal::GarbageCollectionReason, v8::GCCallbackFlag
 s) [node]
 17: 0xd657ac v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int,      v8::internal::AllocationType, v8::internal::AllocationOrigin, v
 8::internal::AllocationAlignment) [node]
 18: 0xd33e5b v8::internal::Factory::NewFillerObject(int, bool,      v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
 19: 0x107c5af v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
 20: 0x1423279  [node]
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! gui@0.1.0 start: `react-scripts start`
 npm ERR! Exit status 1
 npm ERR! 
 npm ERR! Failed at the gui@0.1.0 start script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging      output above.

 npm ERR! A complete log of this run can be found in:
 npm ERR!     /home/bitnami/.npm/_logs/2021-07-28T21_07_20_268Z-debug.log

So I investigated that error and most of the said to use:

export NODE_OPTIONS=--max_old_space_size=4096

So not the good side is that there is not error after setting the SPACE SIZE BUT the bad side is that it stays stuck on:

> gui@0.1.0 start /opt/bitnami/apache/htdocs/GeThaText/frontend/gui
> react-scripts start
Starting the development server...

My package.json:

{
"name": "gui",
"version": "0.1.0",
"private": true,
"dependencies": {
  "@ant-design/icons": "^4.2.1",
  "@material-ui/core": "^4.11.2",
  "@material-ui/icons": "^4.11.2",
  "ant-design": "^1.0.0",
  "antd": "^4.7.0",
  "axios": "^0.21.1",
  "bootstrap": "^4.5.2",
  "dotenv": "^10.0.0",
  "material-table": "^1.69.2",
  "node-sass": "^4.14.1",
  "react": "^16.14.0",
  "react-copy-to-clipboard": "^5.0.2",
  "react-dom": "^16.13.1",
  "react-facebook-login": "^4.1.1",
  "react-google-login": "^5.2.2",
  "react-google-recaptcha": "^2.1.0",
  "react-redux": "^7.2.1",
  "react-router-config": "^5.1.1",
  "react-router-dom": "^5.2.0",
  "react-scripts": "^3.4.2",
  "react-text-loop": "^2.3.0",
  "redux": "^4.0.5",
  "redux-thunk": "^2.3.0"
},
"scripts": {
  "start": "react-scripts start",
  "build": "react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
  ">0.2%",
  "not dead",
  "not op_mini all"
],
"development": [
  "last 1 chrome version",
  "last 1 firefox version",
  "last 1 safari version"
]
},
"devDependencies": {
  "eslint": "^6.6.0",
  "eslint-plugin-react": "^7.24.0",
  "less-loader": "^6.2.0",
  "sass": "^1.34.1",
  "sass-loader": "^11.1.1"
}
}

Any Idea what might be the issue?🤔 🙏🏽 (on my computer Macbook M1 it works). P.S I tried using a simple react project and it worked perfectly

4
  • It seems like an issue with some code. Is the repo public ?
    – Jacksonkr
    Jul 29, 2021 at 1:46
  • Might be, but it does work on my Mac which is weird a bit if it does and the problem is with the code (attaching repo link to the question) Jul 29, 2021 at 8:35
  • Works on Mac, not PC ? If you're on PC I would assume Windows 10 and if that's the case are you using WSL / WSL 2 ? That may make all the difference.
    – Jacksonkr
    Jul 29, 2021 at 19:55
  • 1
    The light sail instance is Unix so not related to Windows Jul 30, 2021 at 11:44

2 Answers 2

2

My Conclusion

You're likely getting runtime errors and because you're running on lightsail the errors are probably going to a log somewhere, not your console.

Why I say that

I downloaded and installed your repo locally (w10h wsl1). Install went fine but on run I ran into errors where any imports from Components or Containers were failing because the folder names are lowercase in the file tree. After doing an entire project find & replace for both folder names the project launches as expected.

Cheers

0

While I lack insight into relevant details of AWS Lightsail, this behavior looks like a classic example of memory starvation. Basically as memory usage gets close to the limit, performance will crawl to a halt (which can be experienced as freezing or hanging) as the system is swapping or trying to GC.

Wikipedia has a brief entry on how this can manifest with virtual memory/swap:

When the system memory is highly insufficient for the current tasks and a large portion of memory activity goes through a slow swap, the system can become practically unable to execute any task, even if the CPU is idle. When every process is waiting on the swap, the system is considered to be in swap death.

Swap death can happen due to incorrectly configured memory overcommitment.

The original description of the "swapping to death" problem relates to the X server. If code or data used by the X server to respond to a keystroke is not in main memory, then if the user enters a keystroke, the server will take one or more page faults, requiring those pages to read from swap before the keystroke can be processed, slowing the response to it. If those pages don't remain in memory, they will have to be faulted in again to handle the next keystroke, making the system practically unresponsive even if it's actually executing other tasks normally.

Your options are either to reduce memory usage or provision additional memory for the task.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.