next.js: JavaScript heap out of memory

Bug report

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Go to git-amp-firt-example
  2. Run
  3. See error

System information

  • OS: Windows 10 update november 14
  • Version of Next.js: 9.1 (npx create-next-app) -Node.js: v12.13.0, v13

Additional context

`<— JS stacktrace —>

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF7885D094F napi_wrap+124431 2: 00007FF788572696 v8::base::CPU::has_sse+34502 3: 00007FF788573356 v8::base::CPU::has_sse+37766 4: 00007FF788D76F4E v8::Isolate::ReportExternalAllocationLimitReached+94 5: 00007FF788D5EF91 v8::SharedArrayBuffer::Externalize+833 6: 00007FF788C2C85C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436 7: 00007FF788C37C00 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312 8: 00007FF788C34734 v8::internal::Heap::PageFlagsAreConsistent+3204 9: 00007FF788C29FC3 v8::internal::Heap::CollectGarbage+1283 10: 00007FF788C2C9AA v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1770 11: 00007FF788C23053 v8::base::CPU::has_vfp3+467 12: 00007FF78851E73C v8::internal::wasm::SignatureMap::Freeze+120892 13: 00007FF78851D6E0 v8::internal::wasm::SignatureMap::Freeze+116704 14: 00007FF788619AAB uv_async_send+331 15: 00007FF78861924C uv_loop_init+1212 16: 00007FF788619414 uv_run+244 17: 00007FF78853B892 EVP_CIPHER_CTX_buf_noconst+30946 18: 00007FF788599263 node::Start+275 19: 00007FF78845666C RC4_options+339308 20: 00007FF789255D58 v8::internal::SetupIsolateDelegate::SetupHeap+1301368 21: 00007FF94D627BD4 BaseThreadInitThunk+20 22: 00007FF94D9ACED1 RtlUserThreadStart+33 error Command failed with exit code 134. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`

With 4gb for node options, any code change result in the same error.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 11
  • Comments: 16 (4 by maintainers)

Most upvoted comments

I have the same issue, my reason is that there are too many routes, just reduce the route.

I was able to run this example without the above error. I think this is likely an issue specific to your machine. I’d instead search on Stackoverflow for possible solutions or maybe ask there.

In my case, it was a pretty stupid mistake. I had this layout component which sets the header and sidebar component and returns with its children in the main section. I don’t know what happened but I called the layout component inside the layout component resulting in a recursive layout call which hanged my laptop 3 times :p

(Just wanted to add that for beginners…)

I get this running next build on next 10, anyone else figured that out?

I faced the same issue, updated my node version to 14, it stayed just to back to read my code and realised i was naming the functional component Card, and also the return being Card yet not imported from reactstrap, so it was doing a recursive.

I had this layout component which sets the header and sidebar component and returns with its children in the main section.

Yep, same exact thing here. I wanted to make a custom Head component so I can simplify the top of my pages. That way a simple <Head title={} /> would do the trick. It was as follows:

import Head from 'next/head';

function Head({ title }) {
  return (
    <Head>
      <title>{title}</title>
      <link rel="icon" href="/favicon.ico" />
    </Head>
  );
}

export default Head;

I’m sure you can see the issue, lol. Just renaming it to something else like CustomHead worked.

I did try to also do import * as NextHead from 'next/head'; but that didn’t seem to work. Though, not a big deal.