@checkstack/healthcheck-script-backend 0.8.3 → 0.8.4

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @checkstack/healthcheck-script-backend
2
2
 
3
+ ## 0.8.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [52c55bf]
8
+ - Updated dependencies [d9f4654]
9
+ - Updated dependencies [21e0d88]
10
+ - Updated dependencies [52c55bf]
11
+ - Updated dependencies [e430fbe]
12
+ - Updated dependencies [eab80e3]
13
+ - Updated dependencies [d2d49cf]
14
+ - Updated dependencies [0d912a3]
15
+ - @checkstack/healthcheck-common@1.10.0
16
+ - @checkstack/common@0.19.0
17
+ - @checkstack/backend-api@0.27.0
18
+ - @checkstack/script-packages-backend@0.3.19
19
+ - @checkstack/secrets-common@0.2.8
20
+
3
21
  ## 0.8.3
4
22
 
5
23
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/healthcheck-script-backend",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
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.26.1",
18
- "@checkstack/common": "0.18.0",
19
- "@checkstack/healthcheck-common": "1.9.0",
20
- "@checkstack/script-packages-backend": "0.3.18",
21
- "@checkstack/secrets-common": "0.2.7"
17
+ "@checkstack/backend-api": "0.27.0",
18
+ "@checkstack/common": "0.19.0",
19
+ "@checkstack/healthcheck-common": "1.10.0",
20
+ "@checkstack/script-packages-backend": "0.3.19",
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.6.5"
27
+ "@checkstack/scripts": "0.7.0"
28
28
  },
29
29
  "description": "Checkstack healthcheck-script-backend plugin",
30
30
  "author": {
@@ -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
- async function countLeakedTmpDirs(): Promise<number> {
22
- const entries = await readdir(tmpdir());
23
- return entries.filter((name) => name.startsWith(TMP_PREFIX)).length;
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 = new InlineScriptCollector();
72
- const before = await countLeakedTmpDirs();
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 countLeakedTmpDirs();
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 = new InlineScriptCollector();
97
- const before = await countLeakedTmpDirs();
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 countLeakedTmpDirs();
141
+ const after = await countLeaked();
118
142
  expect(after).toBe(before);
143
+ await cleanup();
119
144
  }, 30_000);
120
145
  });
121
146