@nxtedition/lib 26.7.0 → 26.8.1

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 (3) hide show
  1. package/app.js +9 -1
  2. package/http.js +9 -9
  3. package/package.json +1 -1
package/app.js CHANGED
@@ -702,7 +702,10 @@ export function makeApp(appConfig, onTerminate) {
702
702
  ),
703
703
  rx.map(([serviceStats, appStats, undiciStats]) => ({
704
704
  ...appStats,
705
- undici: undiciStats,
705
+ undici: {
706
+ sockets: globalThis.__undici_sockets?.size,
707
+ ...undiciStats,
708
+ },
706
709
  [serviceName]: serviceStats,
707
710
  })),
708
711
  rx.retryWhen((err$) =>
@@ -771,6 +774,11 @@ export function makeApp(appConfig, onTerminate) {
771
774
  undici$.pipe(
772
775
  rx.map((stats) => {
773
776
  return [
777
+ {
778
+ id: 'app:undici_upstream_sockets',
779
+ level: stats.sockets > 8192 ? 50 : stats.sockets > 4096 ? 40 : 30,
780
+ msg: `Undici: ${stats.sockets} upstream connected`,
781
+ },
774
782
  {
775
783
  id: 'app:undici_upstream_connections',
776
784
  level: stats.connections > 8192 ? 50 : stats.connections > 4096 ? 40 : 30,
package/http.js CHANGED
@@ -364,15 +364,7 @@ export async function requestMiddleware(ctx, next) {
364
364
  stats.pending--
365
365
  }
366
366
 
367
- if (res.writableEnded || res.destroyed || res.stream?.destroyed) {
368
- // Do nothing..
369
- } else {
370
- res.on('error', noop)
371
- res.destroy()
372
- ctx.logger?.warn('request destroyed')
373
- }
374
-
375
- {
367
+ if (ctx[kPendingIndex] !== -1) {
376
368
  const idx = ctx[kPendingIndex]
377
369
  const tmp = pending.pop()
378
370
  if (tmp !== ctx) {
@@ -381,6 +373,14 @@ export async function requestMiddleware(ctx, next) {
381
373
  tmp[kPendingIndex] = -1
382
374
  }
383
375
  }
376
+
377
+ if (res.writableEnded || res.destroyed || res.stream?.destroyed) {
378
+ // Do nothing..
379
+ } else {
380
+ res.on('error', noop)
381
+ res.destroy()
382
+ ctx.logger?.warn('request destroyed')
383
+ }
384
384
  }
385
385
  }
386
386
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.7.0",
3
+ "version": "26.8.1",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",