@nxtedition/lib 26.3.4 → 26.3.6

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.
Files changed (2) hide show
  1. package/http.js +17 -1
  2. package/package.json +1 -1
package/http.js CHANGED
@@ -199,10 +199,14 @@ export async function upgradeMiddleware(ctx, next) {
199
199
  }
200
200
 
201
201
  export async function requestMiddleware(ctx, next) {
202
- const { req, res, target } = ctx
202
+ const { req, res, target, stats } = ctx
203
203
  const startTime = performance.now()
204
204
 
205
205
  const reqLogger = ctx.logger?.child({ req })
206
+
207
+ if (stats?.pending != null) {
208
+ stats.pending++
209
+ }
206
210
  try {
207
211
  const isHealthcheck = req.url === '/healthcheck' || req.url === '/_up'
208
212
  if (!isHealthcheck) {
@@ -243,6 +247,10 @@ export async function requestMiddleware(ctx, next) {
243
247
  throw new Error('Response not completed')
244
248
  }
245
249
 
250
+ if (stats?.completed != null) {
251
+ stats.completed++
252
+ }
253
+
246
254
  const elapsedTime = performance.now() - startTime
247
255
 
248
256
  if (isHealthcheck) {
@@ -259,6 +267,10 @@ export async function requestMiddleware(ctx, next) {
259
267
  reqLogger?.debug({ res, elapsedTime }, 'request completed')
260
268
  }
261
269
  } catch (err) {
270
+ if (stats?.failed != null) {
271
+ stats.failed++
272
+ }
273
+
262
274
  ctx[kAbortController]?.abort(err)
263
275
 
264
276
  if (!req.closed) {
@@ -338,6 +350,10 @@ export async function requestMiddleware(ctx, next) {
338
350
  res.destroy(err)
339
351
  }
340
352
  } finally {
353
+ if (stats?.pending != null) {
354
+ stats.pending--
355
+ }
356
+
341
357
  if (res.writableEnded || res.destroyed || res.stream?.destroyed) {
342
358
  // Do nothing..
343
359
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.3.4",
3
+ "version": "26.3.6",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",