Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Node Process crashes with 'Call stack exceeded' error in zone-node on Node 10 #1164

Closed
justinappler opened this issue Nov 20, 2018 · 9 comments · Fixed by #1170
Closed

Node Process crashes with 'Call stack exceeded' error in zone-node on Node 10 #1164

justinappler opened this issue Nov 20, 2018 · 9 comments · Fixed by #1170

Comments

@justinappler
Copy link

zone.js version: 0.8.26
Node Version: 10.13.0

When running my Angular Universal application in Node 10.13, using zone.js/dist/zone-node version 0.8.26, the process crashes at startup with the following Stack Trace:

/app/node_modules/zone.js/dist/zone-node.js:240
                throw err;
                ^

RangeError: Maximum call stack size exceeded
    at Zone.scheduleTask (/app/node_modules/zone.js/dist/zone-node.js:239:36)
    at Zone.scheduleEventTask (/app/node_modules/zone.js/dist/zone-node.js:258:25)
    at process.prependListener (/app/node_modules/zone.js/dist/zone-node.js:1744:33)
    at process.on (domain.js:152:13)
    at ZoneDelegate.invokeTask (/app/node_modules/zone.js/dist/zone-node.js:421:31)
    at Zone.runTask (/app/node_modules/zone.js/dist/zone-node.js:188:47)
    at ZoneTask.invokeTask (/app/node_modules/zone.js/dist/zone-node.js:496:34)
    at process.ZoneTask.invoke (/app/node_modules/zone.js/dist/zone-node.js:485:48)
    at process.emit (events.js:187:15)
    at process.EventEmitter.emit (domain.js:442:20)
    at _addListener (events.js:211:14)
    at process.prependListener [as __zone_symbol__prependListener] (events.js:266:14)
    at ZoneTask.customSchedulePrepend [as scheduleFn] (/app/node_modules/zone.js/dist/zone-node.js:1622:47)
    at ZoneDelegate.scheduleTask (/app/node_modules/zone.js/dist/zone-node.js:407:26)
    at Zone.scheduleTask (/app/node_modules/zone.js/dist/zone-node.js:232:43)
    at Zone.scheduleEventTask (/app/node_modules/zone.js/dist/zone-node.js:258:25)
    at process.prependListener (/app/node_modules/zone.js/dist/zone-node.js:1744:33)
    at process.on (domain.js:152:13)

The error does not reproduce when I downgrade to Node 8 (8.9.4).

@JiaLiPassion
Copy link
Collaborator

Please provide a reproduce repo, thanks!

@justinappler
Copy link
Author

justinappler commented Nov 20, 2018

@JiaLiPassion I'm having trouble isolating what part of the code is triggering the issue. My instinct was that it had something to do with the Domain API in Node, but a small HTTP server that uses domains and Zone doesn't seem to trigger a repro of this case. It seems to have something to do with calling prependListener as from the stack trace you can see the infinite loop that occurs and causes the stack to overflow.

I'll keep trying to see if I can call these methods to get this to happen.

@nbryan
Copy link

nbryan commented Dec 8, 2018

I'm seeing the same issue after upgrading from Node 8 to 10.14.1. Downgrading resolves it. Sadly I don't have a simple way to reproduce it as this isn't a direct dependency of mine, so I'm not sure how zone.js is being used by my dependency.

@nbryan
Copy link

nbryan commented Dec 8, 2018

It looks like my dependency is specifying 0.8.20. Sorry I can't share it, it's internal to my company. 🙁

@nbryan
Copy link

nbryan commented Dec 10, 2018

I still need to look further into how my dependency uses zone.js, but I'm actually seeing the error when running my unit tests. Specifically, this line from Mocha:

// uncaught exception
process.on('uncaughtException', uncaught);

In a Node console I could reproduce this more directly with:

> require('./path/to/unit/under/test.js');
{ UnitUnderTest: [Function: UnitUnderTest] }
> process.on('uncaughtException', function(err) { console.log(err); });
RangeError: Maximum call stack size exceeded

Still need to look into how we're using zone.js, but thought this might be helpful.

@JiaLiPassion
Copy link
Collaborator

Thanks, @nbryan, is that possible to share your unit test.js?

@nbryan
Copy link

nbryan commented Dec 11, 2018

@JiaLiPassion Actually the reproduction gets even simpler:

require('zone.js');

process.on('uncaughtException', function() {
    console.log('wat');
});

If I run that in the Node REPL I get an error. If I save it to a a file and run it with node file.js I don't.

@JiaLiPassion
Copy link
Collaborator

@nbryan, @justinappler, thanks! I have fixed this one #1170

JiaLiPassion added a commit to JiaLiPassion/zone.js that referenced this issue Dec 12, 2018
JiaLiPassion added a commit to JiaLiPassion/zone.js that referenced this issue Dec 12, 2018
@nbryan
Copy link

nbryan commented Dec 12, 2018

@JiaLiPassion Wow, thanks for the quick responses and turnaround on a fix!

mhevery pushed a commit that referenced this issue Dec 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants