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

Random call stack size exceeded in binaries complied with node v12.2.0 #681

Closed
peakji opened this issue May 12, 2019 · 72 comments
Closed

Random call stack size exceeded in binaries complied with node v12.2.0 #681

peakji opened this issue May 12, 2019 · 72 comments

Comments

@peakji
Copy link

peakji commented May 12, 2019

Thanks for updating pkg to support node v12!

It seems that there is a weird bug causing random Maximum call stack size exceeded errors ONLY in binaries complied by pkg targeting node v12.2.0:

Binary compiled by pkg Run directly through node
node v10.15.3
node v12.2.0 Maximum call stack size exceeded

(Tested on Linux / CentOS 7)

Unfortunately, the original code is part of a proprietary software so I could not post it here. But since it does not deal with files, I'm pretty sure the issue is not related to the snapshot file system.

Here are some stack trace samples, seems fully random, the only thing in common is the RangeError: Maximum call stack size exceeded:

06:25:30 [22016]: events.js:196
06:25:30 [22016]: Reflect.apply(handler, this, args);
06:25:30 [22016]: ^
06:25:30 [22016]: RangeError: Maximum call stack size exceeded
06:25:30 [22016]: at Object.emit (events.js:196:13)
06:25:30 [22016]: at endReadableNT (_stream_readable.js:1130:12)
06:25:30 [22016]: at processTicksAndRejections (internal/process/task_queues.js:84:9)
06:07:11 [11185]: _stream_transform.js:140
06:07:11 [11185]: this._flush((er, data) => {
06:07:11 [11185]: ^
06:07:11 [11185]: RangeError: Maximum call stack size exceeded
06:07:11 [11185]: at String.replace (<anonymous>)
06:07:11 [11185]: at Object.prefinish (_stream_transform.js:140:10)
06:07:11 [11185]: at Object.emit (events.js:196:13)
06:18:41 [18060]: internal/timers.js:531
06:18:41 [18060]: timer._onTimeout();
06:18:41 [18060]: ^
06:18:41 [18060]: RangeError: Maximum call stack size exceeded
06:18:41 [18060]: at listOnTimeout (internal/timers.js:531:17)
06:18:41 [18060]: at processTimers (internal/timers.js:475:7)
@OneBitAhead
Copy link

Same error occurs on Linux / Ubuntu.

Indeed it seems to be VERY random. Here are some of my stack traces:

/snapshot/oba-core/node_modules/cron/lib/cron.js:562
			this._callbacks[i].call(this.context, this.onComplete);
			                   ^

RangeError: Maximum call stack size exceeded
    at CronJob.fireOnTick (/snapshot/oba-core/node_modules/cron/lib/cron.js:562:23)
    at Timeout.callbackWrapper [as _onTimeout] (/snapshot/oba-core/node_modules/cron/lib/cron.js:629:10)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)
events.js:196
    Reflect.apply(handler, this, args);
            ^

RangeError: Maximum call stack size exceeded
    at process.emit (events.js:196:13)
    at processPromiseRejections (internal/process/promises.js:165:18)
    at processTicksAndRejections (internal/process/task_queues.js:90:32)

Besides: You do a great job with pkg!

@OneBitAhead
Copy link

Because "randomness" of bugs is a pain in the *** for a programmer (and nothing to work with easily) I compiled our product code together with a set of round about 300 unit tests.
These tests use a lot of I/O fs commands, event emitters, http server things, etc.

I ran them multiple times hoping to provide a better error description: BUT every time the error occurs at different tests and code segments. So I cannot provide a better description.

@simlevesque
Copy link

Same here. Ubuntu. Not using the file system. It happens at random moments and I'm on 12.2. If I run the program with Node 12.2 without pkg, it works every time. It's only when the app is packaged with pkg using 12.2.

@tarkh
Copy link

tarkh commented Jun 10, 2019

Same here, getting this error in heavy load loops ONLY when program packed with PKG:
UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded

@tarkh
Copy link

tarkh commented Jun 11, 2019

Well, tried to create custom build with latest master version of Node 12.x branch and got the same STACK SIZE error... So maybe its patch related. Waiting for fix or workaround, because on this moment it is almost impossible to work with Node 12 in PKG.
Btw thanx for great soft!

@tobiasmuecksch
Copy link

tobiasmuecksch commented Jun 13, 2019

I can confirm this happens on Debian 9.8 too.

Downgrade to nodeJS 10 removes the issues.

@luxmeter
Copy link

luxmeter commented Jun 18, 2019

Same here on Amazon Linux AMI.
I though it would be my fault and tried to improve my script in several ways but it didn't work.
I'm glad I found this thread. I can also confirm that the issue does not appear with an older version of NodeJs (v10).

My script is running through the lines of a file and generates for each line several async Mongo calls. I didn't use callbacks but the async & await syntax.

@tumasst
Copy link

tumasst commented Jun 18, 2019

CentOS Linux release 7.6.1810, node v12, same problem.

node v10 - ok

@tobiasmuecksch
Copy link

@igorklopov Any thoughts on this issue?

@bergheim
Copy link

Can confirm the same issue on 5.1.11-arch1-1-ARCH #1 SMP PREEMPT x86_64 GNU/Linux. Works fine with node10.

@whisper-bye
Copy link

node v12.6.0 macOS 10.14

@itayayuichiro
Copy link

@peakji
Which version of pkg did you use?

@peakji
Copy link
Author

peakji commented Jul 17, 2019

@itayayuichiro I'm using the latest pkg v4.4.0 which depends on pkg-fetch v2.6.2.

@itayayuichiro
Copy link

Many thanks.

@stripedpajamas
Copy link

stripedpajamas commented Jul 17, 2019

Facing similar random crashes with this error:

internal/timers.js:531
  timer._onTimeout();
        ^
  RangeError: Maximum call stack size exceeded
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

OS: Ubuntu 19.04 x86_64
Kernel: 5.0.0-20-generic

pkg version: pkg@4.4.0

code that was running:

setInterval(asyncfunction, 1500)

binary created with:

npx pkg -t latest-linux-x64 -o out index.js

Happens between 1-3hrs after running.

@eg-be
Copy link

eg-be commented Jul 18, 2019

I'm running into a

RangeError: Maximum call stack size exceeded
    at add_all_in (E:\snapshot\SimulationServer\node_modules\node-opcua-server\dist\server_subscription.js:1177:26)
    at Subscription._collectNotificationData (E:\snapshot\SimulationServer\node_modules\node-opcua-server\dist\server_subscription.js:1103:13)
    at Subscription._harvestMonitoredItems (E:\snapshot\SimulationServer\node_modules\node-opcua-server\dist\server_subscription.js:1140:39)
    at Subscription.process_subscription (E:\snapshot\SimulationServer\node_modules\node-opcua-server\dist\server_subscription.js:788:18)
    at Subscription._tick (E:\snapshot\SimulationServer\node_modules\node-opcua-server\dist\server_subscription.js:917:22)
    at listOnTimeout (internal/timers.js:531:17)
    at processTimers (internal/timers.js:475:7)

too, with packaged binaries.

On windows 7
node 12.6.0
pkg version: pkg@4.4.0

Edit: I cannot reproduce the issue using Node 10.16.0. I have switched back to 10.X for now.

@odellcraig
Copy link

odellcraig commented Jul 27, 2019

I can also confirm the

RangeError: Maximum call stack size exceeded

Using node v12.7.0

Rolling back to node v10 made the error go away.

@MattSandy
Copy link

MattSandy commented Jul 30, 2019

Having the same issue as well, with a very simple script. Works in command line, doesn't work compiled with pkg.

const Crawler = require("js-crawler");
const cheerio = require('cheerio');
const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

rl.question('Enter Domain? ', (answer) => {
    get_links(answer);
});
var $ = {};
function get_links(domain) {
    new Crawler().configure({ depth: 2, maxRequestsPerSecond: 2 }).crawl("http://" + domain, function (page) {
        $ = cheerio.load(page.body);
    }, null, function onAllFinished(crawledUrls) {
        console.log('FINISHED');
        console.log(crawledUrls);
        process.exit();
    });
}

The output shows

Enter Domain? github.com
/snapshot/contact-info/node_modules/js-crawler/crawler.js:167
    this.onAllFinished && this.onAllFinished(this.crawledUrls);
                               ^

RangeError: Maximum call stack size exceeded
    at Crawler._finishedCrawling (/snapshot/contact-info/node_modules/js-crawler/crawler.js:167:32)
    at Request._callback (/snapshot/contact-info/node_modules/js-crawler/crawler.js:188:12)
    at Request.callback (/snapshot/contact-info/node_modules/request/request.js:185:22)
    at Request.emit (events.js:196:13)
    at Request.<anonymous> (/snapshot/contact-info/node_modules/request/request.js:1157:10)
    at Request.emit (events.js:196:13)
    at IncomingMessage.<anonymous> (/snapshot/contact-info/node_modules/request/request.js:1079:12)
    at Object.onceWrapper (events.js:284:20)
    at IncomingMessage.emit (events.js:201:15)
    at endReadableNT (_stream_readable.js:1130:12)
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

@theebasso
Copy link

Same error for me.
Does someone have any lead ? Workaround ?

@tobiasmuecksch
Copy link

@theebasso The only currently known workaround is to downgrade to nodejs 10.

@RezaErfani67
Copy link

RezaErfani67 commented Aug 26, 2019

Same error for me.
Does someone have any lead ?

@gluwer
Copy link

gluwer commented Sep 4, 2019

We have encountered the same exception using 12.2 x86 build on Windows. It happens after some time (several hours later most of the time), but always in the same place in Cosmos DB library.

The stack trace is (for RangeError - Maximum call stack size exceeded):

| 0 | {"assembly":"at new ParallelQueryExecutionContextBase (node_modules\@Azure\cosmos\dist\index.js:2866:24)","method":"new ParallelQueryExecutionContextBase (node_modules\","level":0,"line":2866,"fileName":"azure\cosmos\dist\index.js"}
| 1 | {"assembly":"at new OrderByQueryExecutionContext (node_modules\@Azure\cosmos\dist\index.js:3370:13)","method":"new OrderByQueryExecutionContext (node_modules\","level":1,"line":3370,"fileName":"azure\cosmos\dist\index.js"}
| 2 | {"assembly":"at new PipelinedQueryExecutionContext (node_modules\@Azure\cosmos\dist\index.js:3700:62)","method":"new PipelinedQueryExecutionContext (node_modules\","level":2,"line":3700,"fileName":"azure\cosmos\dist\index.js"}
| 3 | {"assembly":"at QueryIterator. (node_modules\@Azure\cosmos\dist\index.js:3966:46

What is interesting, when it happens once, the exception is now on always triggered in the same place in every case until the node process is restarted. We now also downgraded to node 10 to confirm it is node 12 related.

@jhonore
Copy link

jhonore commented Sep 5, 2019

The same error for me but with a little difference :
It's run on Macos (compiled by PKG and Node)
It's goes to "Maximum call stack size exceeded" on my Debian 8.11 (compiled version)

Node version : 12.6.0

@armenr
Copy link

armenr commented Sep 17, 2019

We're getting the same thing on our code compiled with pkg - and it isn't clear why or how, but downgrade to node10 seems to be the magic key. :)

@rweads0520
Copy link

Downgrade to node 10 is not such a magic key when dependent on features in node 11+.

@mojzu
Copy link

mojzu commented Dec 4, 2019

I added the --public flag the pkg options, it seems to make the "RangeError: Maximum call stack size exceeded" error less frequent, but it does still happen.

@karanssj4
Copy link

@igorklopov are there any plans to address this?

@igorklopov
Copy link
Contributor

The root cause is found. Shipping soon

@MichaelGatesDev
Copy link

Great. Nexe is a cool alternative but there's a fatal bug right now on Windows machines 💀

Can't wait for the update to switch back to pkg

@sgoll
Copy link

sgoll commented Dec 6, 2019

Great. Nexe is a cool alternative but there's a fatal bug right now on Windows machines 💀

Since a lot of people have moved to nexe due to this issue, can you tell us more about that fatal bug? Is it worth switching back to pkg?

igorklopov added a commit to vercel/pkg-fetch that referenced this issue Dec 6, 2019
@MichaelGatesDev
Copy link

MichaelGatesDev commented Dec 7, 2019

Great. Nexe is a cool alternative but there's a fatal bug right now on Windows machines 💀

Since a lot of people have moved to nexe due to this issue, can you tell us more about that fatal bug? Is it worth switching back to pkg?

nexe/nexe#692
nexe/nexe#701

Causes the application to only be runnable in specific instances. I should say 'not usable for production' rather than 'fatal' because it does not cause the application to crash, but rather not to start at all.

For me, my project relies on being able to actually run when it needs to. It appears that the nexe repo is relatively inactive recently and I fear that it will take a while for those merges to happen.

@tarkh
Copy link

tarkh commented Dec 7, 2019

@igorklopov Thanx, compiled and tested on MacOS Catalina, so far so good without random call stack exceeded! Finally we can move on.

@RezaErfani67
Copy link

please update npm package.
@igorklopov

igorklopov added a commit to vercel/pkg-fetch that referenced this issue Dec 7, 2019
* copy

* update versions

* add to patches.json

* fix for vercel/pkg#681
@igorklopov
Copy link
Contributor

Fixed in 4.4.1. Please try

@RezaErfani67
Copy link

@igorklopov
is it OK with version 13.xx of nodejs?
did you test it?

@bergheim
Copy link

bergheim commented Dec 8, 2019

I have tested this for a bit now, and so far it works like a charm. Will update if it ever comes up again.

Hoorayy @igorklopov !

@OneBitAhead
Copy link

Running all our product test cases again: works like charm (node version 12.13)

Thanks @igorklopov !!

@mojzu
Copy link

mojzu commented Dec 9, 2019

Updated to 4.4.1, haven't seen this error again after testing. Thank you for resolving this, and for the rest of pkg!

@geomad
Copy link

geomad commented Dec 11, 2019

I can confirm the error persists on pkg 4.4.1 with node12.2.0-linux-armv7

@ataft
Copy link

ataft commented Dec 11, 2019

@geomad As per https://github.com/zeit/pkg-fetch/pull/76/files?file-filters%5B%5D=.json, it looks like the fix was applied to the following:

  • v12.13.1
  • v10.17.0
  • v8.16.2

@arkasaha2
Copy link

pkg v4.4.1 with node v12.3.1 has been working fine for me..

Thanks @igorklopov !!

@shusson
Copy link

shusson commented Jan 7, 2020

also confirmed fixed in pkg 4.4.2 with node 12.4.0

@peakji
Copy link
Author

peakji commented Apr 28, 2020

I guess it is safe to close the issue now 🚀

@peakji peakji closed this as completed Apr 28, 2020
@denoww
Copy link

denoww commented Apr 30, 2020

I can confirm the error persists on pkg 4.4.8 with node12.2.0-linux-armv7

@ataft
Copy link

ataft commented Apr 30, 2020

@denoww you can see from these comments that the fix was not applied to 12.2.0. It's on 12.13.1 and above.

@sgoll
Copy link

sgoll commented Jun 16, 2020

@denoww you can see from these comments that the fix was not applied to 12.2.0. It's on 12.13.1 and above.

@ataft Unfortunately, 12.2.0 is still the latest prebuilt release for the armv7 platform: https://github.com/vercel/pkg-fetch/releases

I myself was bitten by this issue just now.

@Ks89
Copy link

Ks89 commented Nov 2, 2020

I'm having the same issue. The latest release available for ARMv7 is 12.2.0 and it's very old and affected by this issue.
Is it possible to update prebuilt releases for ARMV7 adding both 12 and 14 latest stable releases (they are both LTS).

thank u.

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