awesome-typescript-loader icon indicating copy to clipboard operation
awesome-typescript-loader copied to clipboard

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

Open aight8 opened this issue 7 years ago • 12 comments

If transpileOnly is true it works. However this is not a permanent solution. Webpack builds very long time and the memory of the webpack process increases over 1.5 GB, until node.js ran out of memory. I literally build just a ts file as entry point which contains console.log('abc').

[at-loader] Using [email protected] from /Users/aight8/my-project/node_modules/typescript and "tsconfig.json" from /Users/aight8/my-project/tsconfig.json.


<--- Last few GCs --->

[25608:0x103801600]    77275 ms: Mark-sweep 1413.5 (1460.0) -> 1413.5 (1459.0) MB, 869.7 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 870 ms) last resort 
[25608:0x103801600]    78150 ms: Mark-sweep 1413.5 (1459.0) -> 1413.5 (1459.0) MB, 874.3 / 0.0 ms  last resort 


<--- JS stacktrace --->

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

Security context: 0x3e17600266a1 <JS Object>
    2: collectExternalModuleReferences [/Users/aight8/my-project/node_modules/typescript/lib/typescript.js:~64581] [pc=0x4b9261bbbb3](this=0x3e5a8a70e261 <JS Global Object>,file=0x3573668695f1 <a SourceFileObject with map 0x9febc156cb9>)
    3: processImportedModules [/Users/aight8/my-project/node_modules/typescript/lib/typescript.js:~64862] [pc=0x4b92626d712](this=0x3e5a8a7...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 5: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
 6: v8::internal::TypeFeedbackVector::New(v8::internal::Isolate*, v8::internal::Handle<v8::internal::TypeFeedbackMetadata>) [/usr/local/bin/node]
 7: v8::internal::SharedFunctionInfo::FindOrCreateLiterals(v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Handle<v8::internal::Context>) [/usr/local/bin/node]
 8: v8::internal::JSFunction::EnsureLiterals(v8::internal::Handle<v8::internal::JSFunction>) [/usr/local/bin/node]
 9: v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [/usr/local/bin/node]
10: v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
11: 0x4b9254843a7

Ts config is currently:

{
    "compilerOptions": {
        "noImplicitAny": false,
        "strictNullChecks": false,
        "moduleResolution": "node",
        "target": "es2017",
        "outDir": "bin",
        "sourceMap": true,
        "module": "commonjs",
        "typeRoots": [
            "node_modules/@types"
        ],
        "pretty": true
    },
    "include": [
        "src"
    ]
}

However I tested various other settings. The error stays the same.

Tested with typescript 2.2.1 and 2.3-nightly

Parallel issue in ts-loader: https://github.com/TypeStrong/ts-loader/issues/502

aight8 avatar Mar 16 '17 08:03 aight8

I'm also affected by this. Happened today after I upgraded all packages (from about 1 month ago). Not sure about the exact cause. Typescript 2.3.0-RC also cause this.

lbguilherme avatar Apr 22 '17 13:04 lbguilherme

Looks like this was fixed by pull https://github.com/Microsoft/TypeScript/pull/15075, issue https://github.com/Microsoft/TypeScript/issues/14628. Will be released as TS 2.3.1 soon.

lbguilherme avatar Apr 23 '17 23:04 lbguilherme

I just tried to upgrade from 2.2.2 to 2.3.1 and I got this error, that I wasn't getting before. So I suppose this PR didn't really fix the problem?

JabX avatar Apr 28 '17 08:04 JabX

I can reproduce in 2.3.1 as well, but not with typescript@next. The fix was NOT released, but resides in master for 2.4.0. They really should release this.

lbguilherme avatar Apr 28 '17 09:04 lbguilherme

I just tried with 2.4.0-dev.20170428 and I still get the issue. 2.2.2 worked fine though.

JabX avatar Apr 28 '17 10:04 JabX

I think we are being hit by different bugs with equal behavior them.

lbguilherme avatar Apr 28 '17 10:04 lbguilherme

This is happening to me no matter what TS version with transpileOnly=true. Tried 2.2.2, 2.3.3, and next. Seems like it must be a bug in awesome-typescript-loader.

evelant avatar May 25 '17 16:05 evelant

Got this error on both loader: ts and awesome. Can't find a solution. Error appears only when running tests on Karma. Propject compiles normally without tests

Opty1712 avatar Jun 09 '17 11:06 Opty1712

I would like to add to this issue. No typescript is being used in my project is the kicker. Same error. Using Babelrc, styleintrc, reduxrc, angualrJS.

See this link too for similar issue possibly related to the moduleConcat plugin --> Link

My source code here for packages and webpack configs --> link.

"webpack": "^3.0.0",
"webpack-dev-server": "^2.5.0"
<--- Last few GCs --->
[5116:0x102804600] 40275580 ms: Scavenge 1355.1 (1424.6) -> 1354.5 (1424.6) MB, 6.2 / 0.0 ms  (+ 11.0 ms in 2671 steps since last GC) allocation failure
[5116:0x102804600] 40275605 ms: Scavenge 1355.3 (1424.6) -> 1355.0 (1425.6) MB, 3.9 / 0.0 ms  (+ 7.1 ms in 2684 steps since last GC) allocation failure
[5116:0x102804600] 40275628 ms: Scavenge 1355.8 (1425.6) -> 1355.5 (1425.6) MB, 3.7 / 0.0 ms  (+ 6.5 ms in 2696 steps since last GC) allocation failure

<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: Scavenger: promoting marked
 Allocation failed - process out of memory
 1: node::Abort() [/usr/local/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
 4: v8::internal::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 5: v8::internal::ScavengingVisitor<(v8::internal::MarksHandling)0, (v8::internal::PromotionMode)0, (v8::internal::LoggingAndProfiling)1>::EvacuateFixedArray(v8::internal::Map*, v8::internal::HeapObject**, v8::internal::HeapObject*) [/usr/local/bin/node]
 6: v8::internal::Heap::Scavenge() [/usr/local/bin/node]
 7: v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: v8::internal::Heap::CollectGarbage(v8::internal::GarbageCollector, char const*, char const*, v8::GCCallbackFlags) [/usr/local/bin/node]
 9: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
10: v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
11: 0x31eb809063a7e

jacebot avatar Jul 30 '17 18:07 jacebot

I am also running into a similar issue. Though mine occurs regardless of transpileOnly. ts-loader works fine.

{
	"compilerOptions": {
		"noImplicitAny": true,
		"removeComments": true,
		"allowJs": true,
		"strictNullChecks": true,
		"baseUrl": "./src",
		"typeRoots": [
			"./node_modules/@types/",
			"./typings/"
		],
		"allowSyntheticDefaultImports": true,
		"target": "es2016",
		"module": "es6",
		"moduleResolution": "node"
	},
	"awesomeTypescriptLoaderOptions": {
		"transpileOnly": true,
		"useBabel": true,
		"useCache": true,
		"cacheDirectory": "./node_modules/.cache/awesome-typescript-loader",
		"useTranspileModule": true
	}
}
[at-loader] Using [email protected] from typescript and "tsconfig.json" from ~/Code/ibm/spm/icm-web/tsconfig.json (in a forked process).

Node#removeSelf is deprecated. Use Node#remove.

<--- Last few GCs --->

[58204:0x103000000]   149309 ms: Mark-sweep 1409.2 (1466.4) -> 1409.2 (1446.9) MB, 1818.5 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1819 ms) last resort
[58204:0x103000000]   151094 ms: Mark-sweep 1409.2 (1446.9) -> 1409.2 (1446.9) MB, 1785.3 / 0.0 ms  last resort


<--- JS stacktrace --->

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

Security context: 0x3fb980729891 <JS Object>
    1: skipPartiallyEmittedExpressions [~/Code/ibm/spm/icm-web/node_modules/typescript/lib/typescript.js:~15387] [pc=0xaea4f4e435](this=0x6b21a5d4199 <an Object with map 0x25b70329cd49>,node=0x469bf189669 <an IdentifierObject with map 0x25b70328e8b1>)
    2: isLeftHandSideExpression [~/Code/ibm/spm/icm-web/node_modules/typescript/lib/typescript.js:~...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [~/.nvm/versions/node/v8.1.3/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [~/.nvm/versions/node/v8.1.3/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [~/.nvm/versions/node/v8.1.3/bin/node]
 4: v8::internal::Factory::NewStruct(v8::internal::InstanceType) [~/.nvm/versions/node/v8.1.3/bin/node]
 5: v8::internal::Factory::NewTuple3(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [~/.nvm/versions/node/v8.1.3/bin/node]
 6: v8::internal::IC::ComputeHandler(v8::internal::LookupIterator*, v8::internal::Handle<v8::internal::Object>) [~/.nvm/versions/node/v8.1.3/bin/node]
 7: v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [~/.nvm/versions/node/v8.1.3/bin/node]
 8: v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [~/.nvm/versions/node/v8.1.3/bin/node]
 9: v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [~/.nvm/versions/node/v8.1.3/bin/node]
10: 0xaea480437d

paul-sachs avatar Aug 01 '17 15:08 paul-sachs

I found that this was happening when I had linked modules with npm link. Setting webpack resolve.symlinks: false seems to have resolved it for me.

https://webpack.js.org/configuration/resolve/#resolve-symlinks

frankwallis avatar Sep 11 '17 16:09 frankwallis

https://github.com/s-panferov/awesome-typescript-loader/issues/395#issuecomment-328581194 solved it for me too

justindavidrossc avatar May 14 '18 21:05 justindavidrossc