Skip to content

Commit d376036

Browse files
committed
Update to 3.1.1
1 parent fb013d2 commit d376036

File tree

6 files changed

+40
-7
lines changed

6 files changed

+40
-7
lines changed

dist/ProtoSSChe.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ const ERRORS = {
4444
WARNING: "warning",
4545
ABORT: "abort",
4646
};
47+
const PROCESS_EVENTS = {
48+
EXIT: "exit",
49+
BEFORE_EXIT: "beforeExit",
50+
DISCONNECT: "disconnect",
51+
MESSAGE: "message",
52+
WORKER_MESSAGE: "workerMessage",
53+
};
4754
const EVENTS = {
4855
DATA: "data",
4956
ERROR: "error",
@@ -77,9 +84,11 @@ function updateEnv() {
7784
}
7885
}
7986
const globalExceptionsAndErrors = {};
87+
const globalProcessListeners = [];
8088
function onGlobalError(error) {
8189
process.on(error, function (err) {
8290
pushGlobalError(error, err);
91+
globalProcessListeners.forEach((cb) => cb(error, err));
8392
});
8493
}
8594
function pushGlobalError(error, err) {
@@ -92,12 +101,18 @@ function uncaughtExceptionGlobal() {
92101
global.onGlobalError = onGlobalError;
93102
global.pushGlobalError = pushGlobalError;
94103
global.globalExceptionsAndErrors = globalExceptionsAndErrors;
104+
global.globalProcessListeners = globalProcessListeners;
95105
} else return;
96106
onGlobalError(ERRORS.UNCAUGHT_EXCEPTION);
97107
onGlobalError(ERRORS.UNCAUGHT_EXCEPTION_MONITOR);
98108
onGlobalError(ERRORS.UNHANDLED_REJECTION);
99109
onGlobalError(ERRORS.UNHANDLED_PROMISE_REJECTION_WARNING);
100110
onGlobalError(ERRORS.WARNING);
111+
onGlobalError(PROCESS_EVENTS.EXIT);
112+
onGlobalError(PROCESS_EVENTS.BEFORE_EXIT);
113+
onGlobalError(PROCESS_EVENTS.DISCONNECT);
114+
onGlobalError(PROCESS_EVENTS.MESSAGE);
115+
onGlobalError(PROCESS_EVENTS.WORKER_MESSAGE);
101116
}
102117
function resetFSInterval() {
103118
clearInterval(sid);

dist/modules/XProtoSSChe.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,13 @@ function getExtendedServerProtoSS(ProtoSSChe) {
105105
};
106106
let firstin = o.collectionRR[0][0];
107107
let lastout = o.collectionRR[count - 1][1];
108-
stats.time = lastout.__timestamp - firstin.__timestamp;
109108
o.collectionRR.forEach((e) => {
110109
stats.avrgTime += e[1].__timestamp - e[0].__timestamp;
111110
stats.units += e[0].__units || 0;
112111
stats.units += e[1].__units || 0;
112+
if (e[1].__timestamp > lastout.__timestamp) lastout = e[1];
113113
});
114+
stats.time = lastout.__timestamp - firstin.__timestamp;
114115
stats.average = stats.avrgTime / count;
115116
o.collectionRR = [];
116117
o.collectionStats.push(stats);
@@ -233,7 +234,7 @@ function getExtendedServerProtoSS(ProtoSSChe) {
233234
if (!response.headersSent) response.writeHead(response.__rcode || 200, headers);
234235
response.end(input, response.__encoding);
235236
response.__timestamp = new Date().getTime();
236-
o.collectionRR.push([request, response]);
237+
if (o.collectionMax > 0) o.collectionRR.push([request, response]);
237238
return o;
238239
}
239240
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "protoss-nodejs-basic",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"author": "Zeta Ret",
55
"license": "MIT",
66
"type": "commonjs",
@@ -21,6 +21,6 @@
2121
"start-ts": "node dist/indexTS.js"
2222
},
2323
"dependencies": {
24-
"@types/protoss-nodejs-basic": "git+https://github.com/ZetaRet/protoss-nodejs-basic-types.git#v3.1.0"
24+
"@types/protoss-nodejs-basic": "git+https://github.com/ZetaRet/protoss-nodejs-basic-types.git#v3.1.1"
2525
}
2626
}

protossdox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"relative": true,
1010
"markdown": true,
1111
"ext": ["js", "ts"],
12-
"version": "3.1.0",
12+
"version": "3.1.1",
1313
"license": "MIT"
1414
}

src/ProtoSSChe.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ const ERRORS = {
5656
ABORT: "abort",
5757
};
5858

59+
const PROCESS_EVENTS = {
60+
EXIT: "exit",
61+
BEFORE_EXIT: "beforeExit",
62+
DISCONNECT: "disconnect",
63+
MESSAGE: "message",
64+
WORKER_MESSAGE: "workerMessage",
65+
};
66+
5967
const EVENTS = {
6068
DATA: "data",
6169
ERROR: "error",
@@ -94,9 +102,11 @@ function updateEnv() {
94102
}
95103

96104
const globalExceptionsAndErrors: any = {};
105+
const globalProcessListeners: any[] = [];
97106
function onGlobalError(error: any) {
98107
process.on(error, function (err) {
99108
pushGlobalError(error, err);
109+
globalProcessListeners.forEach((cb) => cb(error, err));
100110
});
101111
}
102112
function pushGlobalError(error: any, err: any) {
@@ -109,12 +119,18 @@ function uncaughtExceptionGlobal() {
109119
(global as zetaret.node.BasicServerGlobal).onGlobalError = onGlobalError;
110120
(global as zetaret.node.BasicServerGlobal).pushGlobalError = pushGlobalError;
111121
(global as zetaret.node.BasicServerGlobal).globalExceptionsAndErrors = globalExceptionsAndErrors;
122+
(global as zetaret.node.BasicServerGlobal).globalProcessListeners = globalProcessListeners;
112123
} else return;
113124
onGlobalError(ERRORS.UNCAUGHT_EXCEPTION);
114125
onGlobalError(ERRORS.UNCAUGHT_EXCEPTION_MONITOR);
115126
onGlobalError(ERRORS.UNHANDLED_REJECTION);
116127
onGlobalError(ERRORS.UNHANDLED_PROMISE_REJECTION_WARNING);
117128
onGlobalError(ERRORS.WARNING);
129+
onGlobalError(PROCESS_EVENTS.EXIT);
130+
onGlobalError(PROCESS_EVENTS.BEFORE_EXIT);
131+
onGlobalError(PROCESS_EVENTS.DISCONNECT);
132+
onGlobalError(PROCESS_EVENTS.MESSAGE);
133+
onGlobalError(PROCESS_EVENTS.WORKER_MESSAGE);
118134
}
119135

120136
function resetFSInterval() {

src/modules/XProtoSSChe.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ function getExtendedServerProtoSS(ProtoSSChe: zetaret.node.ProtoSSCheCTOR): zeta
118118
};
119119
let firstin = o.collectionRR[0][0];
120120
let lastout = o.collectionRR[count - 1][1];
121-
stats.time = lastout.__timestamp - firstin.__timestamp;
122121
o.collectionRR.forEach((e: any) => {
123122
stats.avrgTime += e[1].__timestamp - e[0].__timestamp;
124123
stats.units += e[0].__units || 0;
125124
stats.units += e[1].__units || 0;
125+
if (e[1].__timestamp > lastout.__timestamp) lastout = e[1];
126126
});
127+
stats.time = lastout.__timestamp - firstin.__timestamp;
127128
stats.average = stats.avrgTime / count;
128129
o.collectionRR = [];
129130
o.collectionStats.push(stats);
@@ -262,7 +263,7 @@ function getExtendedServerProtoSS(ProtoSSChe: zetaret.node.ProtoSSCheCTOR): zeta
262263
if (!response.headersSent) (response as Http2Response).writeHead((response as zetaret.node.AugmentResponse).__rcode || 200, headers);
263264
response.end(input, (response as zetaret.node.AugmentResponse).__encoding as any);
264265
(response as zetaret.node.AugmentResponse).__timestamp = new Date().getTime();
265-
o.collectionRR.push([request, response]);
266+
if (o.collectionMax > 0) o.collectionRR.push([request, response]);
266267
return o;
267268
}
268269
};

0 commit comments

Comments
 (0)