+14
-6
@@ -55,3 +55,4 @@ var cp = require('child_process'); | ||
| var child, timeout, heartbeatTimeout, done, errMsg; | ||
| var child, timeout, timer, done, errMsg; | ||
| var times = 0; | ||
| var emitter = new EventEmitter(); | ||
@@ -110,4 +111,5 @@ var args = Array.isArray(options._args) ? options._args : []; | ||
| child.on('message', function(msg) { | ||
| clearTimeout(heartbeatTimeout); | ||
| heartbeatTimeout = null; | ||
| clearTimeout(timer); | ||
| timer = null; | ||
| times = 0; | ||
| if (msg == MESSAGE) { | ||
@@ -152,5 +154,11 @@ return; | ||
| }, HEARTBEAT_INTERVAL); | ||
| if (!heartbeatTimeout) { | ||
| heartbeatTimeout = setTimeout(errorHandler, HEARTBEAT_TIMEOUT); | ||
| timer = timer || setTimeout(handleTimeout, HEARTBEAT_TIMEOUT); | ||
| } | ||
| function handleTimeout() { | ||
| if (++times > 1) { | ||
| return errorHandler('timeout'); | ||
| } | ||
| timer = null; | ||
| keepAlive(); | ||
| } | ||
@@ -176,3 +184,3 @@ | ||
| function killChild(delay) { | ||
| clearTimeout(heartbeatTimeout); | ||
| clearTimeout(timer); | ||
| clearTimeout(timeout); | ||
@@ -179,0 +187,0 @@ delete cache[key]; |
+13
-5
@@ -10,7 +10,9 @@ var assert = require('assert'); | ||
| var script = options.script; | ||
| var heartbeatTimeout, done; | ||
| var timer, done; | ||
| var times = 0; | ||
| process.on('message', function(msg) { | ||
| clearTimeout(heartbeatTimeout); | ||
| heartbeatTimeout = null; | ||
| clearTimeout(timer); | ||
| timer = null; | ||
| times = 0; | ||
| if (msg == MESSAGE) { | ||
@@ -49,5 +51,11 @@ return; | ||
| }, HEARTBEAT_INTERVAL); | ||
| if (!heartbeatTimeout) { | ||
| heartbeatTimeout = setTimeout(errorHandler, HEARTBEAT_TIMEOUT); | ||
| timer = timer || setTimeout(handleTimeout, HEARTBEAT_TIMEOUT); | ||
| } | ||
| function handleTimeout() { | ||
| if (++times > 1) { | ||
| return errorHandler(); | ||
| } | ||
| timer = null; | ||
| keepAlive(); | ||
| } | ||
@@ -54,0 +62,0 @@ |
+2
-2
| var cp = require('child_process'); | ||
| var HEARTBEAT_INTERVAL = 10000; | ||
| var HEARTBEAT_INTERVAL = 6000; | ||
@@ -60,3 +60,3 @@ function execCmd(execPath, args, callback) { | ||
| HEARTBEAT_INTERVAL: HEARTBEAT_INTERVAL, | ||
| HEARTBEAT_TIMEOUT: HEARTBEAT_INTERVAL * 3, | ||
| HEARTBEAT_TIMEOUT: HEARTBEAT_INTERVAL * 3 + 2000, | ||
| MESSAGE: 'pforkMessage', | ||
@@ -63,0 +63,0 @@ DATA: 'pforkData', |
+1
-1
| { | ||
| "name": "pfork", | ||
| "description": "fork process", | ||
| "version": "0.6.2", | ||
| "version": "0.6.3", | ||
| "main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "author": "avenwu <avenwu@vip.qq.com>", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
13371
1.29%408
3.55%4
-20%