Skip to content

JavaScript heap out of memory when compiling typesafe-joi on v3.4.x #30794

Closed
@hjkcai

Description

@hjkcai

TypeScript Version:

3.4.1, 3.4.2, 3.5.0-dev.20190406

Reproduction:

https://github.com/hjkcai/typesafe-joi/tree/feature/split-files

git clone https://github.com/hjkcai/typesafe-joi.git -b feature/split-files --depth=1
yarn
yarn test

Update: the published version also has this problem. Reproduce using the published version:

mkdir typesafe-joi-issue && cd typesafe-joi-issue
yarn add typescript@next @types/node typesafe-joi joi
echo '{"compilerOptions":{"strict":true}}' > tsconfig.json
echo 'import * as Joi from "typesafe-joi"; console.log(Joi)' > index.ts
npx tsc -p .

Expected behavior:

tsc should work. It works in ts 3.3.

Actual behavior:

  • tsc got out of memory when running tsc -p .
  • tsserver does not response in vscode (tsserver is responsive only in the first opened file. It does not response after opening a second file. There is no useful information when setting trace to verbose, only showing TypeScript Server: canceled request with sequence number xxx)
<--- Last few GCs --->

[237:0x2a86850]    32677 ms: Mark-sweep 1375.1 (1448.2) -> 1375.1 (1448.2) MB, 781.3 / 0.0 ms  allocation failure GC in old space requested
[237:0x2a86850]    33476 ms: Mark-sweep 1375.1 (1448.2) -> 1375.1 (1432.2) MB, 798.5 / 0.0 ms  last resort GC in old space requested
[237:0x2a86850]    34299 ms: Mark-sweep 1375.1 (1432.2) -> 1375.1 (1432.2) MB, 823.4 / 0.0 ms  last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x1488b018427d]
    1: StubFrame [pc: 0x1488b018b394]
Security context: 0x17670b2206a9 <JSObject>
    2: getUnionType(aka getUnionType) [/mnt/c/Users/hjkcai/Projects/typesafe-joi/node_modules/typescript/lib/tsc.js:~33033] [pc=0x1488b06faf5d](this=0x20e577e022e1 <undefined>,types=0x331caa7af049 <JSArray[2]>,unionReduction=1,aliasSymbol=0x20e577e022e1 <undefined>,aliasTypeArguments=0x20e577e022e1 <undefined>)
    3: in...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [node]
 2: 0x88050c [node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
 5: v8::internal::Factory::NewRawOneByteString(int, v8::internal::PretenureFlag) [node]
 6: v8::internal::Factory::NewStringFromOneByte(v8::internal::Vector<unsigned char const>, v8::internal::PretenureFlag) [node]
 7: v8::internal::Factory::NumberToString(v8::internal::Handle<v8::internal::Object>, bool) [node]
 8: v8::internal::Runtime_NumberToStringSkipCache(int, v8::internal::Object**, v8::internal::Isolate*) [node]
 9: 0x1488b018427d
[1]    237 abort (core dumped)  npx tsc -p .

Related Issues:

I saw lots of regression issues about recursion and type inference. typesafe-joi uses lots of recursions. Maybe they are somehow related?

typesafe-joi was crashed once (#28873). @j-oliveras @ahejlsberg Please help!

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptCrashFor flagging bugs which are compiler or service crashes or unclean exits, rather than bad outputFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions