Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Turbopack crashing in dev server after prolonged usage #73921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
soulr344 opened this issue Dec 13, 2024 · 6 comments
Closed

Turbopack crashing in dev server after prolonged usage #73921

soulr344 opened this issue Dec 13, 2024 · 6 comments
Labels
Turbopack Related to Turbopack with Next.js.

Comments

@soulr344
Copy link

Link to the code that reproduces this issue

https://github.com/soulr344/CGPA-calculator

To Reproduce

Run the dev server continuously for some time (a day in my case). (The reproduction link is NOT related in this case, it's present just so the issue doesn't get closed by the bot)

Current vs. Expected behavior

The turbopack dev server crashes after prolonged usage due to failing memory allocation. In this instance, it crashed after a day of continuous, uninterrupted usage.

Last lines in terminal:

<--- Last few GCs --->

[31799:0x3a034cb0] 23773750 ms: Mark-sweep (reduce) 3696.7 (3829.4) -> 3696.7 (3779.2) MB, 413.8 / 0.0 ms  (average mu = 0.324, current mu = 0.037) last resort; GC in old space requested
[31799:0x3a034cb0] 23774179 ms: Mark-sweep (reduce) 3696.7 (3779.2) -> 3696.7 (3767.4) MB, 428.7 / 0.0 ms  (average mu = 0.189, 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: 0xb9c1f0 node::Abort() [next-server (v15.1.0)]
 2: 0xaa27ee  [next-server (v15.1.0)]
 3: 0xd73950 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [next-server (v15.1.0)]
 4: 0xd73cf7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [next-server (v15.1.0)]
 5: 0xf3f18f v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [next-server (v15.1.0)]
 6: 0xf1f158 v8::internal::Factory::CodeBuilder::AllocateCode(bool) [next-server (v15.1.0)]
 7: 0xf330cc v8::internal::Factory::CodeBuilder::BuildInternal(bool) [next-server (v15.1.0)]
 8: 0xf33b1e v8::internal::Factory::CodeBuilder::Build() [next-server (v15.1.0)]
 9: 0x15ed38e v8::internal::RegExpMacroAssemblerX64::GetCode(v8::internal::Handle<v8::internal::String>) [next-server (v15.1.0)]
10: 0x12b1e86 v8::internal::RegExpCompiler::Assemble(v8::internal::Isolate*, v8::internal::RegExpMacroAssembler*, v8::internal::RegExpNode*, int, v8::internal::Handle<v8::internal::String>) [next-server (v15.1.0)]
11: 0x12d1db7 v8::internal::RegExpImpl::Compile(v8::internal::Isolate*, v8::internal::Zone*, v8::internal::RegExpCompileData*, v8::base::Flags<v8::internal::RegExpFlag, int>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::String>, bool, unsigned int&) [next-server (v15.1.0)]
12: 0x12d2532 v8::internal::RegExpImpl::CompileIrregexp(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, bool) [next-server (v15.1.0)]
13: 0x12d30ee v8::internal::RegExpImpl::IrregexpPrepare(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>) [next-server (v15.1.0)]
14: 0x12d3293 v8::internal::RegExpImpl::IrregexpExec(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, int, v8::internal::Handle<v8::internal::RegExpMatchInfo>, v8::internal::RegExp::ExecQuirks) [next-server (v15.1.0)]
15: 0x12f862e v8::internal::Runtime_RegExpExec(int, unsigned long*, v8::internal::Isolate*) [next-server (v15.1.0)]
16: 0x17120b9  [next-server (v15.1.0)]

.next/trace:
trace.txt

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Fri, 22 Nov 2024 16:04:27 +0000
  Available memory (MB): 31799
  Available CPU cores: 32
Binaries:
  Node: 22.6.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.1.0 // Latest available version is detected (15.1.0).
  eslint-config-next: 15.1.0
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

@soulr344 soulr344 added the bug Issue was opened via the bug report template. label Dec 13, 2024
@github-actions github-actions bot added the Turbopack Related to Turbopack with Next.js. label Dec 13, 2024
@feedthejim
Copy link
Contributor

can you give us a bit more info about your setup (how much RAM do you have) and how much RAM Turbopack was using?

@soulr344
Copy link
Author

i don't know about the RAM turbopack was using when it crashed, I'll keep a log incase turbopack crashes again in the future. Anyway I have 32 gigs of RAM which should be more than enough (unless bun has some limit placed by default?)

@hanashiro
Copy link

The same thing here.
I also have 32GB of RAM.

The project is new, so it is very small yet. Sometimes it stops the dev server in a few minutes

Running dmesg | tail -n 20 I got:

Out of memory: Killed process 30323 (next-server (v1) total-vm:33503344kB, anon-rss:2913100kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:12192kB oom_score_adj:0

Next server was using more than 3GB of memory.

@timneutkens
Copy link
Member

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

This indicates Node.js running out of memory, but Turbopack does not run in Node.js, it runs in Rust. Could you try to reproduce while running with webpack as well? That way there will be a better pointer of where to search for the reason it happens. Right now it could be anything:

  • Turbopack
  • Next.js internals
  • Your code running

Thanks in advance!

@soulr344
Copy link
Author

It's most likely a memory leak in Next.js itself, since it used to crash randomly before turbopack was released (in webpack). And it probably isn't a problem with my code since I've had the dev server crash on multiple projects. One thing in common with all those occurrences is that the dev server crashes when I've not restarted the dev server for more than a day.

@samcx samcx removed the bug Issue was opened via the bug report template. label Jan 23, 2025
@timneutkens
Copy link
Member

timneutkens commented Apr 30, 2025

We've reduced memory usage of Turbopack a lot in Next.js 15.2: https://nextjs.org/blog/next-15-2#turbopack-performance-improvements.

Unfortunately we can't investigate further based on the details you have provided so I'm going to close this issue.

It's most likely a memory leak in Next.js itself

We're not aware of any leaks currently. If this is your assessment we highly recommend sharing performance profiling and details on the exact memory usage in a plain Next.js application, not your application, to rule out any external factors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Turbopack Related to Turbopack with Next.js.
Projects
None yet
Development

No branches or pull requests

5 participants