@nxtedition/lib 22.1.1 → 22.1.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 +51 -41
  2. package/package.json +1 -1
package/app.js CHANGED
@@ -818,61 +818,46 @@ export function makeApp(appConfig, onTerminate) {
818
818
  inspectBC.onmessage = ({ data }) => {
819
819
  const { type, id } = data
820
820
 
821
- if (id !== threadId) {
822
- return
823
- }
824
-
825
- if (type === 'inspect:open') {
826
- // TODO (fix): What happens if you call inspect:open multiple times?
827
- if (!inspectOpen) {
828
- inspector.open(data.port, data.hostname)
829
- inspectOpen = true
830
- }
831
- } else if (type === 'inspect:close') {
832
- if (inspectOpen) {
833
- inspector.close()
834
- inspectOpen = false
821
+ if (id === threadId) {
822
+ if (type === 'inspect:open') {
823
+ // TODO (fix): What happens if you call inspect:open multiple times?
824
+ if (!inspectOpen) {
825
+ inspector.open(data.port, data.hostname)
826
+ inspectOpen = true
827
+ }
828
+ } else if (type === 'inspect:close') {
829
+ if (inspectOpen) {
830
+ inspector.close()
831
+ inspectOpen = false
832
+ }
835
833
  }
836
834
  }
837
835
  }
838
-
839
- inspectBC.postMessage({
840
- type: 'inspect:register',
841
- id: threadId,
842
- worker: {
843
- id: threadId,
844
- name: serviceName,
845
- module: serviceModule,
846
- version: serviceVersion,
847
- workerId: serviceWorkerId,
848
- instanceId: serviceInstanceId,
849
- threadId,
850
- processId: process.pid,
851
- },
852
- })
853
- destroyers.unshift(() => {
854
- if (inspectOpen) {
855
- inspector.close()
856
- inspectOpen = false
857
- }
858
- inspectBC.postMessage({ type: 'inspect:unregister', id: threadId })
859
- setTimeout(() => {
860
- inspectBC.close()
861
- }, 100)
862
- })
863
836
  } else {
864
837
  const inspectMap = new Map()
865
838
 
866
839
  inspectBC.onmessage = ({ data }) => {
867
- const { type, worker } = data
840
+ const { type, worker, id } = data
868
841
 
869
842
  if (type === 'inspect:register') {
870
843
  inspectMap.set(data.id, worker)
871
844
  } else if (type === 'inspect:unregister') {
872
845
  inspectMap.delete(data.id)
846
+ } else if (id === threadId) {
847
+ if (type === 'inspect:open') {
848
+ // TODO (fix): What happens if you call inspect:open multiple times?
849
+ if (!inspectOpen) {
850
+ inspector.open(data.port, data.hostname)
851
+ inspectOpen = true
852
+ }
853
+ } else if (type === 'inspect:close') {
854
+ if (inspectOpen) {
855
+ inspector.close()
856
+ inspectOpen = false
857
+ }
858
+ }
873
859
  }
874
860
  }
875
- destroyers.unshift(() => inspectBC.close())
876
861
 
877
862
  // TODO (fix): Determinisitc port also in dev mode... hash of something?
878
863
  const port =
@@ -938,6 +923,31 @@ export function makeApp(appConfig, onTerminate) {
938
923
 
939
924
  destroyers.unshift(() => new Promise((resolve) => server.close(resolve)))
940
925
  }
926
+
927
+ inspectBC.postMessage({
928
+ type: 'inspect:register',
929
+ id: threadId,
930
+ worker: {
931
+ id: threadId,
932
+ name: serviceName,
933
+ module: serviceModule,
934
+ version: serviceVersion,
935
+ workerId: serviceWorkerId,
936
+ instanceId: serviceInstanceId,
937
+ threadId,
938
+ processId: process.pid,
939
+ },
940
+ })
941
+ destroyers.unshift(() => {
942
+ if (inspectOpen) {
943
+ inspector.close()
944
+ inspectOpen = false
945
+ }
946
+ inspectBC.postMessage({ type: 'inspect:unregister', id: threadId })
947
+ setTimeout(() => {
948
+ inspectBC.close()
949
+ }, 100)
950
+ })
941
951
  }
942
952
 
943
953
  if (appConfig.utils !== false && !cluster.isWorker) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "22.1.1",
3
+ "version": "22.1.3",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",