🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

pfork

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pfork - npm Package Compare versions

Comparing version
0.6.2
to
0.6.3
+14
-6
lib/index.js

@@ -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];

@@ -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 @@

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',

{
"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>",