@nsshunt/stsinstrumentmanagerclient 1.0.13 → 1.0.15

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
@@ -149,10 +149,8 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
149
149
  "UpdateInstrument_AR_DEC"
150
150
  /* UpdateInstrument_AR_DEC */
151
151
  );
152
- let timeInMs = 0;
153
- const end = process.hrtime(start);
154
- timeInMs = (end[0] * 1e9 + end[1]) / 1e6;
155
- timeInMs = parseFloat(timeInMs.toFixed(4));
152
+ const end = performance.now() - start;
153
+ const timeInMs = parseFloat(end.toFixed(4));
156
154
  this.#tinyEmitter.emit("UpdateInstrument_DH_VAL", timeInMs);
157
155
  this.#tinyEmitter.emit("UpdateInstrument_D_VAL", timeInMs);
158
156
  console.log(`-->>ZZZ: ${timeInMs}`);
@@ -171,9 +169,15 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
171
169
  */
172
170
  Middleware = async (req, res, next) => {
173
171
  if (this.options.ignoresocketio && req.originalUrl.includes("socket.io")) {
174
- return;
172
+ return next();
175
173
  }
176
- const start = process.hrtime();
174
+ const start = performance.now();
175
+ let completed = false;
176
+ const completeOnce = () => {
177
+ if (completed) return;
178
+ completed = true;
179
+ this.#RequestCompleted(start);
180
+ };
177
181
  this.#tinyEmitter.emit(
178
182
  "UpdateInstrument_AR_INC"
179
183
  /* UpdateInstrument_AR_INC */
@@ -188,12 +192,13 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
188
192
  );
189
193
  req.on("aborted", () => {
190
194
  });
191
- req.on("close", () => {
192
- this.#RequestCompleted(start);
193
- });
194
195
  req.on("end", () => {
195
196
  });
197
+ res.on("close", () => {
198
+ completeOnce();
199
+ });
196
200
  res.on("finish", () => {
201
+ completeOnce();
197
202
  });
198
203
  next();
199
204
  };