@nxtedition/lib 26.8.2 → 26.8.3

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/app.js +15 -80
  2. package/package.json +10 -10
package/app.js CHANGED
@@ -35,7 +35,6 @@ import { monitorEventLoopDelay } from 'node:perf_hooks'
35
35
  import xuid from 'xuid'
36
36
  import { isTimeBetween } from './time.js'
37
37
  import makeUnderPressure from './under-pressure.js'
38
- import undici from '@nxtedition/undici'
39
38
  import { isPrimary } from 'node:cluster'
40
39
  import { nice } from '@nxtedition/sched'
41
40
  import { setAffinity } from './numa.js'
@@ -550,65 +549,6 @@ export function makeApp(appConfig, onTerminate) {
550
549
  compiler = makeTemplateCompiler({ ds, logger, ...appConfig.compiler })
551
550
  }
552
551
 
553
- const undiciDefaults = Object.freeze({
554
- connected: 0,
555
- disconnected: 0,
556
- connections: 0,
557
- })
558
-
559
- const undici$ = new rxjs.BehaviorSubject({ ...undiciDefaults })
560
- {
561
- function onConnect(origin, targets) {
562
- const stats = { ...undici$.value }
563
- stats.connected++
564
- stats.connections = stats.connected - stats.disconnected
565
- undici$.next(stats)
566
- logger.debug({ url: origin, count: stats.connected }, 'upstream connect')
567
- }
568
-
569
- function onDisconnect(origin, targets, err) {
570
- const stats = { ...undici$.value }
571
- stats.connected--
572
- stats.connections = stats.connected - stats.disconnected
573
- undici$.next(stats)
574
- logger.debug({ url: origin, count: stats.connected }, 'upstream disconnect')
575
- }
576
-
577
- let currentDispatcher
578
- function maybeRegisterUndiciStats() {
579
- const nextDispatcher = undici.getGlobalDispatcher()
580
-
581
- if (nextDispatcher === currentDispatcher) {
582
- return
583
- }
584
-
585
- if (currentDispatcher) {
586
- currentDispatcher.off('connect', onConnect).off('disconnect', onDisconnect)
587
- currentDispatcher = null
588
- }
589
-
590
- undici$.next({ ...undiciDefaults })
591
-
592
- nextDispatcher.on('connect', onConnect).on('disconnect', onDisconnect)
593
-
594
- currentDispatcher = nextDispatcher
595
- }
596
-
597
- let undiciInterval = setInterval(() => maybeRegisterUndiciStats(), 10e3).unref()
598
-
599
- destroyers.push(() => {
600
- if (undiciInterval) {
601
- clearInterval(undiciInterval)
602
- undiciInterval = null
603
- }
604
-
605
- if (currentDispatcher) {
606
- currentDispatcher.off('connect', onConnect).off('disconnect', onDisconnect)
607
- currentDispatcher = null
608
- }
609
- })
610
- }
611
-
612
552
  const monitorProviders = {}
613
553
 
614
554
  let stats$
@@ -695,17 +635,15 @@ export function makeApp(appConfig, onTerminate) {
695
635
  userAgent,
696
636
  pending: globalThis._nxt_lib_http_pending?.size,
697
637
  },
638
+ undici: {
639
+ sockets: globalThis.__undici_sockets?.size ?? 0,
640
+ },
698
641
  }
699
642
  }),
700
643
  ),
701
- undici$,
702
644
  ),
703
- rx.map(([serviceStats, appStats, undiciStats]) => ({
645
+ rx.map(([serviceStats, appStats]) => ({
704
646
  ...appStats,
705
- undici: {
706
- sockets: globalThis.__undici_sockets?.size,
707
- ...undiciStats,
708
- },
709
647
  [serviceName]: serviceStats,
710
648
  })),
711
649
  rx.retryWhen((err$) =>
@@ -771,20 +709,17 @@ export function makeApp(appConfig, onTerminate) {
771
709
  rx.distinctUntilChanged(fp.isEqual),
772
710
  rx.repeatWhen((complete$) => complete$.pipe(rx.delay(10e3))),
773
711
  ),
774
- undici$.pipe(
775
- rx.map((stats) => {
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
- },
782
- {
783
- id: 'app:undici_upstream_connections',
784
- level: stats.connections > 8192 ? 50 : stats.connections > 4096 ? 40 : 30,
785
- msg: `Undici: ${stats.connections} upstream connected`,
786
- },
787
- ]
712
+ stats$.pipe(
713
+ rx.map(({ undici: stats }) => {
714
+ return stats
715
+ ? [
716
+ {
717
+ id: 'app:undici_upstream_sockets',
718
+ level: stats.sockets > 8192 ? 50 : stats.sockets > 4096 ? 40 : 30,
719
+ msg: `Undici: ${stats.sockets} upstream connected`,
720
+ },
721
+ ]
722
+ : []
788
723
  }),
789
724
  ),
790
725
  toobusy?.appLag$.pipe(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "26.8.2",
3
+ "version": "26.8.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",
@@ -65,12 +65,12 @@
65
65
  "singleQuote": true
66
66
  },
67
67
  "dependencies": {
68
- "@aws-sdk/client-s3": "3.901.0",
68
+ "@aws-sdk/client-s3": "3.918.0",
69
69
  "@elastic/elasticsearch": "^8.17.1",
70
70
  "@elastic/transport": "^8.9.3",
71
- "@nxtedition/nxt-undici": "^6.4.0",
71
+ "@nxtedition/nxt-undici": "^6.4.17",
72
72
  "@nxtedition/sched": "^1.0.2",
73
- "@smithy/node-http-handler": "^4.3.0",
73
+ "@smithy/node-http-handler": "^4.4.3",
74
74
  "acorn": "^8.15.0",
75
75
  "astring": "^1.9.0",
76
76
  "date-fns": "^4.1.0",
@@ -87,7 +87,7 @@
87
87
  "nconf": "^0.13.0",
88
88
  "object-hash": "^3.0.0",
89
89
  "p-queue": "^9.0.0",
90
- "pino": "^10.0.0",
90
+ "pino": "^10.1.0",
91
91
  "qs": "^6.14.0",
92
92
  "request-target": "^1.0.2",
93
93
  "smpte-timecode": "^1.3.6",
@@ -97,11 +97,11 @@
97
97
  "yocto-queue": "^1.2.1"
98
98
  },
99
99
  "devDependencies": {
100
- "@nxtedition/deepstream.io-client-js": ">=31.0.18",
100
+ "@nxtedition/deepstream.io-client-js": ">=31.2.1",
101
101
  "@types/lodash": "^4.17.20",
102
- "@types/node": "^24.7.0",
102
+ "@types/node": "^24.9.1",
103
103
  "canvas": "^3.1.0",
104
- "eslint": "^9.37.0",
104
+ "eslint": "^9.38.0",
105
105
  "eslint-config-prettier": "^10.1.8",
106
106
  "eslint-config-standard": "^17.0.0",
107
107
  "eslint-plugin-import": "^2.32.0",
@@ -109,11 +109,11 @@
109
109
  "eslint-plugin-node": "^11.1.0",
110
110
  "eslint-plugin-promise": "^7.2.1",
111
111
  "husky": "^9.1.7",
112
- "lint-staged": "^16.2.3",
112
+ "lint-staged": "^16.2.6",
113
113
  "prettier": "^3.6.2",
114
114
  "rxjs": "^7.8.2",
115
115
  "typescript": "^5.9.3",
116
- "typescript-eslint": "^8.46.0"
116
+ "typescript-eslint": "^8.46.2"
117
117
  },
118
118
  "peerDependencies": {
119
119
  "@elastic/elasticsearch": "^8.6.0",