prisma: `tsc --watch` fails with `JavaScript heap out of memory` error

Bug description

Related issue: https://github.com/prisma/prisma/issues/10183#issuecomment-1643701334 (@aqrln)

When run tsc --watch command and edit some codes using prisma, about two minutes being consumed, and such error being occurred. For reference, such bug does not occur when running only tsc command. Also, does not occur in tsc --watch command until do update, either.

  • tsc: works fine
  • tsc --watch and do not anything: works fine
  • tsc --watch and update something: error

I also tried to avoid the bug by assigning much more memory, but same bug still occurs, and needed much more minutes to get the same error message.

  • node --max-old-space-size=4096 node_modules/typescript/bin/tsc --watch
[9:05:36 PM] File change detected. Starting incremental compilation...


<--- Last few GCs --->

[6216:000001C592CE9A30]   135933 ms: Mark-Compact 4045.6 (4133.3) -> 4030.8 (4134.3) MB, 808.22 / 0.00 ms  (average mu = 0.107, current mu = 0.031) allocation failure; scavenge might not succeed
[6216:000001C592CE9A30]   136760 ms: Mark-Compact 4046.6 (4134.3) -> 4031.9 (4135.5) MB, 798.19 / 0.00 ms  (average mu = 0.072, current mu = 0.035) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF723D45B3F node_api_throw_syntax_error+202639
 2: 00007FF723CC2366 v8::base::CPU::num_virtual_address_bits+66502
 3: 00007FF723CC4181 v8::base::CPU::num_virtual_address_bits+74209
 4: 00007FF72472B4B1 v8::Isolate::ReportExternalAllocationLimitReached+65
 5: 00007FF724714C18 v8::Function::Experimental_IsNopFunction+1336
 6: 00007FF7245765B0 v8::Platform::SystemClockTimeMillis+659552
 7: 00007FF724582833 v8::Platform::SystemClockTimeMillis+709347
 8: 00007FF724580194 v8::Platform::SystemClockTimeMillis+699460
 9: 00007FF7245732D0 v8::Platform::SystemClockTimeMillis+646528
10: 00007FF72458894A v8::Platform::SystemClockTimeMillis+734202
11: 00007FF7245891C7 v8::Platform::SystemClockTimeMillis+736375
12: 00007FF724597B43 v8::Platform::SystemClockTimeMillis+796147
13: 00007FF7242581D5 v8::CodeEvent::GetFunctionName+116821
14: 00007FF6C479AAFA

How to reproduce

I don’t know how to reproduce it.

Such bug had not occurred when project is small, but started being happened when project being larger.

As this project is commercial project that is not opened public, I’m sorry to cannot share with you.

If a reproducible repo must be, I’ll try it next month \o/.

Expected behavior

No problem when running tsc --watch and updating source code.

Prisma information

Sorry for cannot write prisma schema content due to commercial project.

Environment & setup

  • OS: Windows 11
  • Database: Postgres v15
  • Node.js version: v20.4.0

Prisma Version

prisma                  : 5.0.0
@prisma/client          : 5.0.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 6b0aef69b7cdfc787f822ecd7cdc76d5f1991584 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine           : schema-engine-cli 6b0aef69b7cdfc787f822ecd7cdc76d5f1991584 (at node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm             : @prisma/prisma-schema-wasm 4.17.0-26.6b0aef69b7cdfc787f822ecd7cdc76d5f1991584
Default Engines Hash    : 6b0aef69b7cdfc787f822ecd7cdc76d5f1991584
Studio                  : 0.487.0

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Since I had two reports via DM that this is fixed on our @prisma/client@dev tag (= main branch), I am closing this issue. We have received reports of enums being impacted by recent changes (unrelated to the fix for this issue) and also have a fix up for review. If you want to try the “type oom” fix + “enum” fix, you can install this version 5.1.0-integration-fix-client-enums.1.

Thanks all of you.

Ah, nice point. 4.16.0 seems to be okay. However, 4.16.1 seems to be where the behavior was introduced.

Same behaviour while using prisma client extensions. TypeScript v5.1.6

Hey @peterarusanoff 👋 I’d appreciate if you could create a new issue for us with the necessary info for us to reproduce it. Thanks!