@nxtedition/lib 22.1.0 → 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.
- package/app.js +51 -43
- package/package.json +1 -1
package/app.js
CHANGED
|
@@ -56,8 +56,6 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
56
56
|
undici.setGlobalDispatcher(new undici.Agent({ connectTimeout: 2e3 }))
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
v8.setHeapSnapshotNearHeapLimit(3)
|
|
60
|
-
|
|
61
59
|
// Optimize some Node global defaults.
|
|
62
60
|
|
|
63
61
|
Buffer.poolSize = 128 * 1024
|
|
@@ -820,61 +818,46 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
820
818
|
inspectBC.onmessage = ({ data }) => {
|
|
821
819
|
const { type, id } = data
|
|
822
820
|
|
|
823
|
-
if (id
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
inspectOpen
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
inspector.close()
|
|
836
|
-
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
|
+
}
|
|
837
833
|
}
|
|
838
834
|
}
|
|
839
835
|
}
|
|
840
|
-
|
|
841
|
-
inspectBC.postMessage({
|
|
842
|
-
type: 'inspect:register',
|
|
843
|
-
id: threadId,
|
|
844
|
-
worker: {
|
|
845
|
-
id: threadId,
|
|
846
|
-
name: serviceName,
|
|
847
|
-
module: serviceModule,
|
|
848
|
-
version: serviceVersion,
|
|
849
|
-
workerId: serviceWorkerId,
|
|
850
|
-
instanceId: serviceInstanceId,
|
|
851
|
-
threadId,
|
|
852
|
-
processId: process.pid,
|
|
853
|
-
},
|
|
854
|
-
})
|
|
855
|
-
destroyers.unshift(() => {
|
|
856
|
-
if (inspectOpen) {
|
|
857
|
-
inspector.close()
|
|
858
|
-
inspectOpen = false
|
|
859
|
-
}
|
|
860
|
-
inspectBC.postMessage({ type: 'inspect:unregister', id: threadId })
|
|
861
|
-
setTimeout(() => {
|
|
862
|
-
inspectBC.close()
|
|
863
|
-
}, 100)
|
|
864
|
-
})
|
|
865
836
|
} else {
|
|
866
837
|
const inspectMap = new Map()
|
|
867
838
|
|
|
868
839
|
inspectBC.onmessage = ({ data }) => {
|
|
869
|
-
const { type, worker } = data
|
|
840
|
+
const { type, worker, id } = data
|
|
870
841
|
|
|
871
842
|
if (type === 'inspect:register') {
|
|
872
843
|
inspectMap.set(data.id, worker)
|
|
873
844
|
} else if (type === 'inspect:unregister') {
|
|
874
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
|
+
}
|
|
875
859
|
}
|
|
876
860
|
}
|
|
877
|
-
destroyers.unshift(() => inspectBC.close())
|
|
878
861
|
|
|
879
862
|
// TODO (fix): Determinisitc port also in dev mode... hash of something?
|
|
880
863
|
const port =
|
|
@@ -940,6 +923,31 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
940
923
|
|
|
941
924
|
destroyers.unshift(() => new Promise((resolve) => server.close(resolve)))
|
|
942
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
|
+
})
|
|
943
951
|
}
|
|
944
952
|
|
|
945
953
|
if (appConfig.utils !== false && !cluster.isWorker) {
|