Skip to content

TS 5.1.3 Regression: TSC Compiler throws FATAL ERROR: Reached heap limit Allocation failedΒ #54491

@virtuallyunknown

Description

@virtuallyunknown

Bug Report

πŸ”Ž Search Terms

tsc, compiler, heap limit, crash, memory

πŸ•— Version & Regression Information

  • This is a crash
  • This changed between versions 5.0.4 and 5.1.3

⏯ Repository Link

https://github.com/virtuallyunknown/tsc-error

πŸ’» Code

To reproduce the error, clone the repository and run the build script or just npx tsc.

git clone https://github.com/virtuallyunknown/tsc-error.git && cd tsc-error
npm install
npx tsc

πŸ™ Actual behavior

Running the typescript compiler (tsc) from project root causes the build to fail and produce this error:

<--- Last few GCs --->

[43355:0x6bd0ae0]     9563 ms: Scavenge 4038.1 (4116.6) -> 4037.2 (4117.8) MB, 4.5 / 0.0 ms  (average mu = 0.538, current mu = 0.113) allocation failure; 
[43355:0x6bd0ae0]     9572 ms: Scavenge 4039.0 (4117.8) -> 4038.2 (4138.6) MB, 8.4 / 0.0 ms  (average mu = 0.538, current mu = 0.113) allocation failure; 
[43355:0x6bd0ae0]    10371 ms: Mark-Compact 4052.2 (4138.6) -> 4048.8 (4152.1) MB, 794.9 / 0.0 ms  (average mu = 0.390, current mu = 0.040) allocation failure; scavenge might not succeed

<--- JS stacktrace --->

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
 1: 0xbf9890 node::Abort() [node]
 2: 0xaf6859  [node]
 3: 0xddaf80 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0xddb336 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 5: 0xfd9db5  [node]
 6: 0xfed4e5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 7: 0xfc924f v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 8: 0xfca297 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
 9: 0xfa99fa v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
10: 0x13bd76f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x18443f9  [node]
Aborted (core dumped)

I also tried typescript@next, but that doesn't fix it. I also tried this command:

NODE_OPTIONS=--max-old-space-size=28000 npx tsc --noEmit --diagnostics --extendedDiagnostics --incremental false

but it crashes with a different error after a while.

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

πŸ™‚ Expected behavior

Running the typescript compiler (tsc) command compiles the build successfully after 1-2 seconds, just like it did in 5.0.4.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFix AvailableA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions