Skip to content
This repository was archived by the owner on Dec 1, 2019. It is now read-only.

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

Open
aight8 opened this issue Mar 16, 2017 · 12 comments

Comments

@aight8
Copy link

aight8 commented Mar 16, 2017

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 typescript@2.2.1 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: TypeStrong/ts-loader#502

@lbguilherme
Copy link

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
Copy link

Looks like this was fixed by pull microsoft/TypeScript#15075, issue microsoft/TypeScript#14628. Will be released as TS 2.3.1 soon.

@JabX
Copy link

JabX commented Apr 28, 2017

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?

@lbguilherme
Copy link

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.

@JabX
Copy link

JabX commented Apr 28, 2017

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

@lbguilherme
Copy link

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

@evelant
Copy link

evelant commented May 25, 2017

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.

@Opty1712
Copy link

Opty1712 commented Jun 9, 2017

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

@jacebot
Copy link

jacebot commented Jul 30, 2017

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

@paul-sachs
Copy link

paul-sachs commented Aug 1, 2017

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 typescript@2.4.2 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

@frankwallis
Copy link

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

@justindavidrossc
Copy link

#395 (comment) solved it for me too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants