@nsshunt/stsinstrumentmanagerclient 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs
CHANGED
|
@@ -153,7 +153,6 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
|
|
|
153
153
|
const timeInMs = parseFloat(end.toFixed(4));
|
|
154
154
|
this.#tinyEmitter.emit("UpdateInstrument_DH_VAL", timeInMs);
|
|
155
155
|
this.#tinyEmitter.emit("UpdateInstrument_D_VAL", timeInMs);
|
|
156
|
-
console.log(`-->>ZZZ: ${timeInMs}`);
|
|
157
156
|
};
|
|
158
157
|
// https://stackoverflow.com/questions/18031839/how-to-use-process-hrtime-to-get-execution-time-of-async-function/18031945
|
|
159
158
|
/**
|
|
@@ -169,9 +168,15 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
|
|
|
169
168
|
*/
|
|
170
169
|
Middleware = async (req, res, next) => {
|
|
171
170
|
if (this.options.ignoresocketio && req.originalUrl.includes("socket.io")) {
|
|
172
|
-
return;
|
|
171
|
+
return next();
|
|
173
172
|
}
|
|
174
173
|
const start = performance.now();
|
|
174
|
+
let completed = false;
|
|
175
|
+
const completeOnce = () => {
|
|
176
|
+
if (completed) return;
|
|
177
|
+
completed = true;
|
|
178
|
+
this.#RequestCompleted(start);
|
|
179
|
+
};
|
|
175
180
|
this.#tinyEmitter.emit(
|
|
176
181
|
"UpdateInstrument_AR_INC"
|
|
177
182
|
/* UpdateInstrument_AR_INC */
|
|
@@ -186,12 +191,13 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
|
|
|
186
191
|
);
|
|
187
192
|
req.on("aborted", () => {
|
|
188
193
|
});
|
|
189
|
-
req.on("close", () => {
|
|
190
|
-
this.#RequestCompleted(start);
|
|
191
|
-
});
|
|
192
194
|
req.on("end", () => {
|
|
193
195
|
});
|
|
196
|
+
res.on("close", () => {
|
|
197
|
+
completeOnce();
|
|
198
|
+
});
|
|
194
199
|
res.on("finish", () => {
|
|
200
|
+
completeOnce();
|
|
195
201
|
});
|
|
196
202
|
next();
|
|
197
203
|
};
|