pinokiod 7.5.23 → 7.5.25
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/kernel/api/index.js +20 -8
- package/kernel/procs.js +4 -2
- package/package.json +1 -1
- package/test/launch-requirements.test.js +27 -0
- package/test/procs.test.js +3 -3
package/kernel/api/index.js
CHANGED
|
@@ -575,20 +575,32 @@ class Api {
|
|
|
575
575
|
// 1. if the scropt has 'on.stop', run it when stopping
|
|
576
576
|
let requestPath = this.filePath(req.params.uri)
|
|
577
577
|
this.clearResolvedAction(requestPath)
|
|
578
|
-
let
|
|
579
|
-
|
|
578
|
+
let cwd
|
|
579
|
+
let script
|
|
580
|
+
try {
|
|
581
|
+
const resolved = await this.resolveScript(requestPath)
|
|
582
|
+
cwd = resolved.cwd
|
|
583
|
+
script = resolved.script
|
|
584
|
+
} catch (e) {
|
|
585
|
+
if (!e || e.code !== "ENOENT") {
|
|
586
|
+
throw e
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (script && script.on) {
|
|
580
590
|
if (script.on.stop) {
|
|
581
591
|
await this.process(script.on.stop)
|
|
582
592
|
}
|
|
583
593
|
}
|
|
584
594
|
// reset modules
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
595
|
+
if (cwd) {
|
|
596
|
+
let modpath = this.resolvePath(cwd, req.params.uri)
|
|
597
|
+
if (this.child_procs[modpath]) {
|
|
598
|
+
let child_procs = Array.from(this.child_procs[modpath])
|
|
599
|
+
for(let proc of child_procs) {
|
|
600
|
+
delete this.mods[proc]
|
|
601
|
+
}
|
|
602
|
+
delete this.child_procs[modpath]
|
|
590
603
|
}
|
|
591
|
-
delete this.child_procs[modpath]
|
|
592
604
|
}
|
|
593
605
|
|
|
594
606
|
|
package/kernel/procs.js
CHANGED
|
@@ -73,13 +73,15 @@ class Procs {
|
|
|
73
73
|
let pids = new Set()
|
|
74
74
|
let s = stdout.trim()
|
|
75
75
|
const lines = s.split('\n');
|
|
76
|
+
const listeningForeignAddresses = new Set(['0.0.0.0:0', '[::]:0', '*:*', '*:0'])
|
|
76
77
|
for(let line of lines) {
|
|
77
78
|
if (isWin) {
|
|
78
79
|
// Skip headers
|
|
79
80
|
try {
|
|
80
81
|
if (!line.startsWith(' TCP')) continue;
|
|
81
82
|
const parts = line.trim().split(/\s+/);
|
|
82
|
-
const [ , localAddress,
|
|
83
|
+
const [ , localAddress, foreignAddress ] = parts;
|
|
84
|
+
const pid = parts[parts.length - 1]
|
|
83
85
|
|
|
84
86
|
let pid_int = parseInt(pid)
|
|
85
87
|
if (pid_int === 0 || pid_int === 4) {
|
|
@@ -88,7 +90,7 @@ class Procs {
|
|
|
88
90
|
continue
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
if (
|
|
93
|
+
if (!listeningForeignAddresses.has(foreignAddress)) continue;
|
|
92
94
|
const chunks = /(.+):([0-9]+)/.exec(localAddress)
|
|
93
95
|
let host = chunks[1]
|
|
94
96
|
let port = chunks[2]
|
package/package.json
CHANGED
|
@@ -1153,6 +1153,33 @@ test("api.stop stops the canonical script path when the visible run id is decora
|
|
|
1153
1153
|
})
|
|
1154
1154
|
})
|
|
1155
1155
|
|
|
1156
|
+
test("api.stop disconnects when the script was deleted before stop cleanup", async () => {
|
|
1157
|
+
await withApiStopFixture(async ({ api, launchPath, killedGroups, stopped, packets }) => {
|
|
1158
|
+
const decoratedId = `${launchPath}?cwd=undefined`
|
|
1159
|
+
api.resolveScript = async () => {
|
|
1160
|
+
const error = new Error("missing script")
|
|
1161
|
+
error.code = "ENOENT"
|
|
1162
|
+
throw error
|
|
1163
|
+
}
|
|
1164
|
+
api.running[launchPath] = true
|
|
1165
|
+
api.running[decoratedId] = true
|
|
1166
|
+
api.kernel.memory.local[launchPath] = { live: true }
|
|
1167
|
+
api.kernel.memory.local[decoratedId] = { live: true }
|
|
1168
|
+
|
|
1169
|
+
await api.stop({ params: { id: decoratedId } })
|
|
1170
|
+
|
|
1171
|
+
assert.equal(api.running[launchPath], undefined)
|
|
1172
|
+
assert.equal(api.running[decoratedId], undefined)
|
|
1173
|
+
assert.equal(api.kernel.memory.local[launchPath], undefined)
|
|
1174
|
+
assert.equal(api.kernel.memory.local[decoratedId], undefined)
|
|
1175
|
+
assert.ok(killedGroups.includes(launchPath), "canonical script group must be killed")
|
|
1176
|
+
assert.ok(killedGroups.includes(decoratedId), "visible run id group must remain stopped")
|
|
1177
|
+
assert.equal(stopped.length, 1)
|
|
1178
|
+
assert.equal(stopped[0].scriptPath, launchPath)
|
|
1179
|
+
assert.ok(packets.some((packet) => packet.type === "disconnect" && packet.id === decoratedId))
|
|
1180
|
+
})
|
|
1181
|
+
})
|
|
1182
|
+
|
|
1156
1183
|
test("startup launch request does not block on its own startup status row", async () => {
|
|
1157
1184
|
await withFixtureApps({
|
|
1158
1185
|
target: {}
|
package/test/procs.test.js
CHANGED
|
@@ -16,7 +16,7 @@ function loadProcsForPlatform(platform) {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
test("Windows process parser only probes listening TCP rows", async () => {
|
|
19
|
+
test("Windows process parser only probes listening TCP rows without relying on localized state text", async () => {
|
|
20
20
|
const Procs = loadProcsForPlatform("win32")
|
|
21
21
|
const procs = new Procs({})
|
|
22
22
|
const probed = []
|
|
@@ -28,8 +28,8 @@ test("Windows process parser only probes listening TCP rows", async () => {
|
|
|
28
28
|
|
|
29
29
|
const stdout = [
|
|
30
30
|
" Proto Local Address Foreign Address State PID",
|
|
31
|
-
" TCP 127.0.0.1:5173 0.0.0.0:0
|
|
32
|
-
" TCP 127.0.0.1:49153 127.0.0.1:5173
|
|
31
|
+
" TCP 127.0.0.1:5173 0.0.0.0:0 ABHOEREN 1111",
|
|
32
|
+
" TCP 127.0.0.1:49153 127.0.0.1:5173 HERGESTELLT 2222",
|
|
33
33
|
" TCP 0.0.0.0:7860 0.0.0.0:0 LISTENING 3333",
|
|
34
34
|
" TCP [::1]:11434 [::]:0 LISTENING 4444"
|
|
35
35
|
].join("\n")
|