Skip to content

Commit 46db3cf

Browse files
If process.uptime() < 20 seconds don't enforce worker exit count limit
1 parent 4e5737f commit 46db3cf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jsonrpc-bidirectional",
33
"description": "Bidirectional JSONRPC over web sockets or HTTP with extensive plugin support.",
4-
"version": "10.0.10",
4+
"version": "10.0.11",
55
"scripts": {
66
"build": "node --experimental-worker build.js",
77
"prepublish": "node --experimental-worker build.js && node --expose-gc --max-old-space-size=1024 --experimental-worker tests/main.js",

src/NodeClusterBase/MasterEndpoint.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ class MasterEndpoint extends NodeMultiCoreCPUBase.MasterEndpoint
101101
return nMillisecondsUnixTimeOfFailure >= new Date().getTime() - (60 * 2 * 1000);
102102
});
103103

104-
const nMaxFailuresPerMaxWorkers = process.uptime() < 15 /*seconds*/ ? Math.min(this.maxWorkersCount * 2, 20 /*times*/) : 20 /*times*/;
104+
const nMaxFailuresPerMaxWorkers = 20 /*times*/;
105+
106+
if(process.uptime() < 20)
107+
{
108+
this.arrFailureTimestamps.splice(0);
109+
}
110+
105111
if(this.arrFailureTimestamps.length / Math.max(this.maxWorkersCount, 1) > nMaxFailuresPerMaxWorkers)
106112
{
107113
console.error(`[Master] *Not* adding a worker because another worker has died. Doing a .gracefulExit() instead because the number of worker failures divided by .maxWorkersCount is greater than ${nMaxFailuresPerMaxWorkers} over the last 2 minutes. ${this.arrFailureTimestamps.length / Math.max(this.maxWorkersCount, 1)} > ${nMaxFailuresPerMaxWorkers}. Process uptime is ${process.uptime()} seconds.`);

0 commit comments

Comments
 (0)