Random call stack size exceeded in binaries complied with node v12.2.0
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)
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!
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.
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.
Same here, getting this error in heavy load loops ONLY when program packed with PKG:
UnhandledPromiseRejectionWarning: RangeError: Maximum call stack size exceeded
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!
I can confirm this happens on Debian 9.8 too.
Downgrade to nodeJS 10 removes the issues.
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.
CentOS Linux release 7.6.1810, node v12, same problem.
node v10 - ok
@igorklopov Any thoughts on this issue?
Can confirm the same issue on 5.1.11-arch1-1-ARCH #1 SMP PREEMPT x86_64 GNU/Linux. Works fine with node10.
node v12.6.0 macOS 10.14
@peakji
Which version of pkg did you use?
@itayayuichiro I'm using the latest pkg v4.4.0 which depends on pkg-fetch v2.6.2.
Many thanks.
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: [email protected]
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.
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: [email protected]
Edit: I cannot reproduce the issue using Node 10.16.0. I have switched back to 10.X for now.
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.
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]
Same error for me. Does someone have any lead ? Workaround ?
@theebasso The only currently known workaround is to downgrade to nodejs 10.