@nsshunt/stsinstrumentmanagerclient 1.0.14 → 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
@@ -169,9 +169,15 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
169
169
  */
170
170
  Middleware = async (req, res, next) => {
171
171
  if (this.options.ignoresocketio && req.originalUrl.includes("socket.io")) {
172
- return;
172
+ return next();
173
173
  }
174
174
  const start = performance.now();
175
+ let completed = false;
176
+ const completeOnce = () => {
177
+ if (completed) return;
178
+ completed = true;
179
+ this.#RequestCompleted(start);
180
+ };
175
181
  this.#tinyEmitter.emit(
176
182
  "UpdateInstrument_AR_INC"
177
183
  /* UpdateInstrument_AR_INC */
@@ -186,12 +192,13 @@ class RequestLoggerMiddleware extends stsutils.STSOptionsBase {
186
192
  );
187
193
  req.on("aborted", () => {
188
194
  });
189
- req.on("close", () => {
190
- this.#RequestCompleted(start);
191
- });
192
195
  req.on("end", () => {
193
196
  });
197
+ res.on("close", () => {
198
+ completeOnce();
199
+ });
194
200
  res.on("finish", () => {
201
+ completeOnce();
195
202
  });
196
203
  next();
197
204
  };