@checkstack/healthcheck-script-backend 0.8.3 → 0.8.5
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/CHANGELOG.md +27 -0
- package/package.json +7 -7
- package/src/concurrency.test.ts +35 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @checkstack/healthcheck-script-backend
|
|
2
2
|
|
|
3
|
+
## 0.8.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [0cac684]
|
|
8
|
+
- @checkstack/healthcheck-common@1.11.0
|
|
9
|
+
- @checkstack/backend-api@0.27.1
|
|
10
|
+
- @checkstack/script-packages-backend@0.3.20
|
|
11
|
+
|
|
12
|
+
## 0.8.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [52c55bf]
|
|
17
|
+
- Updated dependencies [d9f4654]
|
|
18
|
+
- Updated dependencies [21e0d88]
|
|
19
|
+
- Updated dependencies [52c55bf]
|
|
20
|
+
- Updated dependencies [e430fbe]
|
|
21
|
+
- Updated dependencies [eab80e3]
|
|
22
|
+
- Updated dependencies [d2d49cf]
|
|
23
|
+
- Updated dependencies [0d912a3]
|
|
24
|
+
- @checkstack/healthcheck-common@1.10.0
|
|
25
|
+
- @checkstack/common@0.19.0
|
|
26
|
+
- @checkstack/backend-api@0.27.0
|
|
27
|
+
- @checkstack/script-packages-backend@0.3.19
|
|
28
|
+
- @checkstack/secrets-common@0.2.8
|
|
29
|
+
|
|
3
30
|
## 0.8.3
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/healthcheck-script-backend",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"checkstack": {
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"pack": "bunx @checkstack/scripts plugin-pack"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@checkstack/backend-api": "0.
|
|
18
|
-
"@checkstack/common": "0.
|
|
19
|
-
"@checkstack/healthcheck-common": "1.
|
|
20
|
-
"@checkstack/script-packages-backend": "0.3.
|
|
21
|
-
"@checkstack/secrets-common": "0.2.
|
|
17
|
+
"@checkstack/backend-api": "0.27.1",
|
|
18
|
+
"@checkstack/common": "0.19.0",
|
|
19
|
+
"@checkstack/healthcheck-common": "1.11.0",
|
|
20
|
+
"@checkstack/script-packages-backend": "0.3.20",
|
|
21
|
+
"@checkstack/secrets-common": "0.2.8"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/bun": "^1.0.0",
|
|
25
25
|
"typescript": "^5.0.0",
|
|
26
26
|
"@checkstack/tsconfig": "0.0.7",
|
|
27
|
-
"@checkstack/scripts": "0.
|
|
27
|
+
"@checkstack/scripts": "0.7.0"
|
|
28
28
|
},
|
|
29
29
|
"description": "Checkstack healthcheck-script-backend plugin",
|
|
30
30
|
"author": {
|
package/src/concurrency.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { readdir } from "node:fs/promises";
|
|
2
|
+
import { mkdtemp, readdir, rm } from "node:fs/promises";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
4
5
|
import { InlineScriptCollector } from "./inline-script-collector";
|
|
5
6
|
import { ScriptHealthCheckStrategy } from "./strategy";
|
|
6
7
|
import type { ScriptTransportClient } from "./transport-client";
|
|
@@ -18,9 +19,31 @@ import type { ScriptTransportClient } from "./transport-client";
|
|
|
18
19
|
const PARALLELISM = 20;
|
|
19
20
|
const TMP_PREFIX = "checkstack-script-";
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Create a throwaway base dir and a collector whose per-run scratch dirs are
|
|
24
|
+
* created *inside* it (via `resolutionRoot`). This isolates the leak check
|
|
25
|
+
* from every other test file that also spawns scripts into the shared
|
|
26
|
+
* `os.tmpdir()` — the main source of cross-file flakes. Returns the base dir
|
|
27
|
+
* (caller removes it) plus a `countLeaked()` that only counts dirs under it.
|
|
28
|
+
*/
|
|
29
|
+
async function isolatedScope(): Promise<{
|
|
30
|
+
collector: InlineScriptCollector;
|
|
31
|
+
countLeaked: () => Promise<number>;
|
|
32
|
+
cleanup: () => Promise<void>;
|
|
33
|
+
}> {
|
|
34
|
+
const base = await mkdtemp(join(tmpdir(), "cs-concurrency-test-"));
|
|
35
|
+
const collector = new InlineScriptCollector(
|
|
36
|
+
undefined,
|
|
37
|
+
() => Promise.resolve({ mode: "ready" as const, root: base }),
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
collector,
|
|
41
|
+
countLeaked: async () =>
|
|
42
|
+
(await readdir(base)).filter((n) => n.startsWith(TMP_PREFIX)).length,
|
|
43
|
+
cleanup: async () => {
|
|
44
|
+
await rm(base, { recursive: true, force: true });
|
|
45
|
+
},
|
|
46
|
+
};
|
|
24
47
|
}
|
|
25
48
|
|
|
26
49
|
const mockClient: ScriptTransportClient = {
|
|
@@ -68,8 +91,8 @@ describe("inline-script concurrency", () => {
|
|
|
68
91
|
}, 60_000);
|
|
69
92
|
|
|
70
93
|
it("cleans up temp dirs even when scripts throw", async () => {
|
|
71
|
-
const collector =
|
|
72
|
-
const before = await
|
|
94
|
+
const { collector, countLeaked, cleanup } = await isolatedScope();
|
|
95
|
+
const before = await countLeaked();
|
|
73
96
|
|
|
74
97
|
await Promise.all(
|
|
75
98
|
Array.from({ length: PARALLELISM }, () =>
|
|
@@ -88,13 +111,14 @@ describe("inline-script concurrency", () => {
|
|
|
88
111
|
),
|
|
89
112
|
);
|
|
90
113
|
|
|
91
|
-
const after = await
|
|
114
|
+
const after = await countLeaked();
|
|
92
115
|
expect(after).toBe(before);
|
|
116
|
+
await cleanup();
|
|
93
117
|
}, 60_000);
|
|
94
118
|
|
|
95
119
|
it("cleans up temp dirs when scripts time out", async () => {
|
|
96
|
-
const collector =
|
|
97
|
-
const before = await
|
|
120
|
+
const { collector, countLeaked, cleanup } = await isolatedScope();
|
|
121
|
+
const before = await countLeaked();
|
|
98
122
|
|
|
99
123
|
await Promise.all(
|
|
100
124
|
Array.from({ length: 5 }, () =>
|
|
@@ -114,8 +138,9 @@ describe("inline-script concurrency", () => {
|
|
|
114
138
|
// the kernel can be slow to drop fds on macOS.
|
|
115
139
|
await new Promise((r) => setTimeout(r, 100));
|
|
116
140
|
|
|
117
|
-
const after = await
|
|
141
|
+
const after = await countLeaked();
|
|
118
142
|
expect(after).toBe(before);
|
|
143
|
+
await cleanup();
|
|
119
144
|
}, 30_000);
|
|
120
145
|
});
|
|
121
146
|
|