@nxtedition/lib 21.3.4 → 21.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/app.js +23 -7
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -273,7 +273,7 @@ export function makeApp(appConfig, onTerminate) {
273
273
  }
274
274
  })
275
275
 
276
- setInterval(() => {
276
+ const lagInterval = setInterval(() => {
277
277
  let currentLag = Math.max(0, histogram.mean / 1e6 - resolution)
278
278
  if (Number.isNaN(currentLag)) {
279
279
  currentLag = 0
@@ -295,7 +295,12 @@ export function makeApp(appConfig, onTerminate) {
295
295
  appLag = Math.max(appLag, lag ?? 0)
296
296
  }
297
297
  appLag$.next(appLag)
298
- }, interval).unref()
298
+ }, interval)
299
+
300
+ destroyers.unshift(() => {
301
+ clearInterval(lagInterval)
302
+ lagBC.close()
303
+ })
299
304
 
300
305
  toobusy = () => currentLag$.value > maxLag
301
306
  toobusy.lag = () => currentLag$.value
@@ -453,9 +458,14 @@ export function makeApp(appConfig, onTerminate) {
453
458
  }
454
459
  }
455
460
 
456
- setInterval(() => {
461
+ const memoryUsageInterval = setInterval(() => {
457
462
  memoryUsageBC.postMessage({ data: process.memoryUsage(), id: serviceWorkerId })
458
- }, 1e3).unref()
463
+ }, 1e3)
464
+
465
+ destroyers.unshift(() => {
466
+ clearInterval(memoryUsageInterval)
467
+ memoryUsageBC.close()
468
+ })
459
469
 
460
470
  const startTime = Date.now()
461
471
  stats$ = stats$.pipe(
@@ -796,7 +806,11 @@ export function makeApp(appConfig, onTerminate) {
796
806
 
797
807
  if (serviceWorkerId) {
798
808
  inspectBC.onmessage = ({ data }) => {
799
- const { type } = data
809
+ const { type, id } = data
810
+
811
+ if (id !== serviceWorkerId) {
812
+ return
813
+ }
800
814
 
801
815
  if (type === 'inspect:open') {
802
816
  // TODO (fix): What happens if you call inspect:open multiple times?
@@ -810,6 +824,9 @@ export function makeApp(appConfig, onTerminate) {
810
824
  destroyers.unshift(() => {
811
825
  inspector.close()
812
826
  inspectBC.postMessage({ type: 'inspect:unregister', id: serviceWorkerId })
827
+ setTimeout(() => {
828
+ inspectBC.close()
829
+ }, 100)
813
830
  })
814
831
  } else {
815
832
  inspectBC.onmessage = ({ data }) => {
@@ -821,10 +838,9 @@ export function makeApp(appConfig, onTerminate) {
821
838
  inspectSet.delete(data.id)
822
839
  }
823
840
  }
841
+ destroyers.unshift(() => inspectBC.close())
824
842
  }
825
843
 
826
- destroyers.unshift(() => inspectBC.close())
827
-
828
844
  if (appConfig.http) {
829
845
  const httpConfig = { ...appConfig.http, ...config.http }
830
846
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "21.3.4",
3
+ "version": "21.3.6",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",