Open History to see the last commit
1// @effect-diagnostics nodeBuiltinImport:off - reads the user guide to check its anchors.
2import * as NodeFS from "node:fs";
3import * as NodeNet from "node:net";
4
5import { T3_CONNECT_TROUBLESHOOTING_SECTIONS } from "@t3tools/contracts";
6import * as HostProcess from "@t3tools/shared/HostProcess";
7import { SpawnExecutableResolution, type SpawnExecutableResolver } from "@t3tools/shared/shell";
8import { describe, expect, it } from "@effect/vitest";
9import * as Clock from "effect/Clock";
10import * as Deferred from "effect/Deferred";
11import * as Duration from "effect/Duration";
12import * as Effect from "effect/Effect";
13import * as Fiber from "effect/Fiber";
14import * as Layer from "effect/Layer";
15import * as Queue from "effect/Queue";
16import * as Sink from "effect/Sink";
17import * as Stream from "effect/Stream";
18import * as TestClock from "effect/testing/TestClock";
19import { HttpClient, HttpClientError, HttpClientRequest, HttpClientResponse } from "effect/http";
20import { ChildProcessSpawner } from "effect/process";
21import { vi } from "vite-plus/test";
22
23import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
24import * as ConnectReachability from "./ConnectReachability.ts";
25import { classifyReachability, type ReachabilityFacts } from "./ConnectReachability.ts";
26import * as ManagedEndpointRuntime from "./ManagedEndpointRuntime.ts";
27
28vi.mock("node:net", { spy: true });
29
30const checkedAt = "2026-10-19T00:00:00.000Z";
31const connected = {
32 pid: 1,
33 readyConnections: 4,
34 hostname: "env.example.test",
35 origin: null,
36 protocol: "quic",
37};
38const notConnected = { pid: 1, readyConnections: 0, hostname: null, origin: null, protocol: null };
39const facts = (overrides: Partial<ReachabilityFacts>): ReachabilityFacts => ({
40 managedTunnelConfigured: true,
41 connector: connected,
42 endpoint: null,
43 edgeReachable: null,
44 exitNode: null,
45 ...overrides,
46});
47
48describe("classifyReachability", () => {
49 it.each([
50 [{ kind: "status", status: 502 }, "origin_unreachable"],
51 [{ kind: "status", status: 530 }, "no_connector"],
52 [{ kind: "status", status: 530, cloudflareError: "1033" }, "no_connector"],
53 [{ kind: "status", status: 530, cloudflareError: "1016" }, "dns_failed"],
54 [{ kind: "status", status: 530, cloudflareError: "1001" }, "unexpected_response"],
55 [{ kind: "network_error" }, "timeout"],
56 ] as const)("maps endpoint result %o to %s", (endpoint, cause) => {
57 expect(classifyReachability(facts({ endpoint, edgeReachable: true }), checkedAt)).toMatchObject(
58 { status: "unreachable", cause },
59 );
60 });
61
62 it("keeps the endpoint cause when the TCP edge test cannot explain it", () => {
63 // QUIC (UDP) can connect while TCP 7844 is blocked.
64 expect(
65 classifyReachability(
66 facts({ endpoint: { kind: "status", status: 502 }, edgeReachable: false }),
67 checkedAt,
68 ),
69 ).toMatchObject({ cause: "origin_unreachable" });
70 expect(
71 classifyReachability(
72 facts({
73 connector: {
74 pid: 1,
75 readyConnections: null,
76 hostname: "env.example.test",
77 origin: null,
78 protocol: null,
79 },
80 endpoint: { kind: "status", status: 502 },
81 edgeReachable: false,
82 }),
83 checkedAt,
84 ),
85 ).toMatchObject({ cause: "origin_unreachable" });
86 // Failed DNS also fails the edge lookups.
87 expect(
88 classifyReachability(
89 facts({
90 connector: {
91 pid: 1,
92 readyConnections: null,
93 hostname: "env.example.test",
94 origin: null,
95 protocol: null,
96 },
97 endpoint: { kind: "dns_failed" },
98 edgeReachable: false,
99 }),
100 checkedAt,
101 ),
102 ).toMatchObject({ cause: "dns_failed" });
103 });
104
105 it("waits on a connector that has not connected while the edge answers", () => {
106 expect(
107 classifyReachability(facts({ connector: notConnected, edgeReachable: true }), checkedAt),
108 ).toMatchObject({ cause: "connector_not_ready" });
109 });
110
111 it("does not point an unlinked server at a background service it may not have", () => {
112 // Desktop and `t3 serve` run the server without a background service.
113 const result = classifyReachability(facts({ managedTunnelConfigured: false }), checkedAt);
114 expect(result).toMatchObject({ cause: "not_linked" });
115 expect(result.status === "unreachable" && result.fix).not.toContain("t3 service");
116 });
117});
118
119interface ServedResponse {
120 readonly status: number;
121 readonly body: string | ReadableStream<Uint8Array> | { readonly cloudflareError: number };
122}
123
124// What Cloudflare serves for its 530 page: HTML unless the client accepts JSON.
125const cloudflareErrorPage = (request: HttpClientRequest.HttpClientRequest, code: number) =>
126 request.headers.accept === "application/json"
127 ? JSON.stringify({ status: 530, error_code: code, error_name: "tunnel_error" })
128 : `<!doctype html><h1><span>Error</span> <span>${code}</span></h1>`;
129
130type Served = Effect.Effect<ServedResponse, HttpClientError.HttpClientError>;
131
132const reachabilityLayer = (
133 respond: Served | ((request: HttpClientRequest.HttpClientRequest) => Served),
134 restartConnector: (pid: number, stillDead: Effect.Effect<boolean>) => Effect.Effect<boolean>,
135 options: {
136 readonly connector?: ManagedEndpointRuntime.ConnectorFacts;
137 readonly spawner?: ChildProcessSpawner.ChildProcessSpawner["Service"];
138 readonly resolveExecutable?: SpawnExecutableResolver;
139 } = {},
140) =>
141 ConnectReachability.layer.pipe(
142 Layer.provide(
143 Layer.mergeAll(
144 Layer.mock(ManagedEndpointRuntime.CloudManagedEndpointRuntime)({
145 inspectConnector: Effect.succeed(options.connector ?? connected),
146 readinessChanged: Stream.never,
147 restartConnector,
148 }),
149 Layer.mock(ServerSecretStore.ServerSecretStore)({
150 get: () => Effect.succeedSome(new Uint8Array()),
151 }),
152 Layer.succeed(
153 HttpClient.HttpClient,
154 HttpClient.make((request) =>
155 (Effect.isEffect(respond) ? respond : respond(request)).pipe(
156 Effect.map(({ status, body }) =>
157 HttpClientResponse.fromWeb(
158 request,
159 new Response(
160 typeof body === "object" && "cloudflareError" in body
161 ? cloudflareErrorPage(request, body.cloudflareError)
162 : body,
163 { status },
164 ),
165 ),
166 ),
167 ),
168 ),
169 ),
170 Layer.succeed(
171 ChildProcessSpawner.ChildProcessSpawner,
172 options.spawner ?? ChildProcessSpawner.make(() => Effect.die("no tailscale")),
173 ),
174 Layer.succeed(SpawnExecutableResolution, options.resolveExecutable ?? (() => undefined)),
175 Layer.succeed(HostProcess.Platform, "linux"),
176 ),
177 ),
178 );
179
180const mockEdgeConnect = () =>
181 vi.spyOn(NodeNet, "connect").mockImplementation(() => {
182 const socket = new NodeNet.Socket();
183 queueMicrotask(() => socket.emit("connect"));
184 return socket;
185 });
186
187describe("ConnectReachability stale connector recovery", () => {
188 it.effect("restarts cloudflared when Cloudflare has no connector but it reports ready", () =>
189 Effect.gen(function* () {
190 using _connect = mockEdgeConnect();
191 const restarts = yield* Queue.unbounded<number>();
192 // Cloudflare answers 530 while cloudflared still reports four ready connections.
193 let status = 530;
194 let body = { cloudflareError: 1033 };
195 const layer = reachabilityLayer(
196 Effect.sync(() => ({ status, body })),
197 (pid, stillDead) =>
198 stillDead.pipe(Effect.tap((dead) => (dead ? Queue.offer(restarts, pid) : Effect.void))),
199 );
200 // The scheduled checks run in the layer's scope, so the assertions run inside it.
201 yield* Effect.gen(function* () {
202 const reachability = yield* ConnectReachability.ConnectReachability;
203
204 // The first sighting schedules its own confirming check two minutes later.
205 expect(yield* reachability.check).toMatchObject({ cause: "no_connector" });
206 yield* TestClock.adjust(Duration.minutes(1));
207 expect(yield* Queue.size(restarts)).toBe(0);
208 yield* TestClock.adjust(Duration.minutes(1));
209 expect(yield* Queue.take(restarts)).toBe(connected.pid);
210
211 // A restart that did not help doubles the wait.
212 yield* reachability.check;
213 yield* TestClock.adjust(Duration.minutes(2));
214 expect(yield* Queue.size(restarts)).toBe(0);
215 yield* TestClock.adjust(Duration.minutes(2));
216 expect(yield* Queue.take(restarts)).toBe(connected.pid);
217
218 // Reaching the endpoint resets the wait, and a 530 for a broken DNS record is left alone.
219 status = 200;
220 expect(yield* reachability.check).toMatchObject({ status: "reachable" });
221 status = 530;
222 body = { cloudflareError: 1016 };
223 expect(yield* reachability.check).toMatchObject({ cause: "dns_failed" });
224 yield* TestClock.adjust(Duration.minutes(2));
225 expect(yield* Queue.size(restarts)).toBe(0);
226
227 body = { cloudflareError: 1033 };
228 yield* reachability.check;
229 yield* TestClock.adjust(Duration.minutes(2));
230 expect(yield* Queue.take(restarts)).toBe(connected.pid);
231 }).pipe(Effect.provide(layer));
232 }),
233 );
234
235 it.effect("starts a new streak after a healthy check that a newer check overtook", () =>
236 Effect.gen(function* () {
237 using _connect = mockEdgeConnect();
238 const restartTimes = yield* Queue.unbounded<number>();
239 const healthyRequested = yield* Deferred.make<void>();
240 const healthyAnswer = yield* Deferred.make<void>();
241 let status = 530;
242 const layer = reachabilityLayer(
243 Effect.gen(function* () {
244 const served = status;
245 if (served === 200) {
246 yield* Deferred.succeed(healthyRequested, undefined);
247 yield* Deferred.await(healthyAnswer);
248 }
249 return { status: served, body: { cloudflareError: 1033 } };
250 }),
251 (_pid, stillDead) =>
252 stillDead.pipe(
253 Effect.tap((dead) =>
254 dead
255 ? Clock.currentTimeMillis.pipe(
256 Effect.flatMap((now) => Queue.offer(restartTimes, now)),
257 )
258 : Effect.void,
259 ),
260 ),
261 );
262 yield* Effect.gen(function* () {
263 const reachability = yield* ConnectReachability.ConnectReachability;
264 const startedAt = yield* Clock.currentTimeMillis;
265 yield* reachability.check;
266 yield* TestClock.adjust(Duration.minutes(1));
267
268 // The healthy answer arrives after a newer check already reported the tunnel dead.
269 status = 200;
270 const healthy = yield* Effect.forkChild(reachability.check);
271 yield* Deferred.await(healthyRequested);
272 status = 530;
273 yield* reachability.check;
274 yield* Deferred.succeed(healthyAnswer, undefined);
275 expect(yield* Fiber.join(healthy)).toMatchObject({ status: "reachable" });
276
277 // The grace period starts again at the next dead check, a minute after the first one.
278 yield* reachability.check;
279 yield* TestClock.adjust(Duration.minutes(2));
280 expect((yield* Queue.take(restartTimes)) - startedAt).toBe(
281 Duration.toMillis(Duration.minutes(3)),
282 );
283 }).pipe(Effect.provide(layer));
284 }),
285 );
286
287 it.effect("rejects a restart when an overtaken healthy check finishes while it waits", () =>
288 Effect.gen(function* () {
289 using _connect = mockEdgeConnect();
290 const healthyRequested = yield* Deferred.make<void>();
291 const healthyAnswer = yield* Deferred.make<void>();
292 const restartRequested = yield* Deferred.make<void>();
293 const releaseRestart = yield* Deferred.make<void>();
294 const guardChecks = yield* Queue.unbounded<boolean>();
295 let status = 530;
296 const layer = reachabilityLayer(
297 Effect.gen(function* () {
298 const served = status;
299 if (served === 200) {
300 yield* Deferred.succeed(healthyRequested, undefined);
301 yield* Deferred.await(healthyAnswer);
302 }
303 return { status: served, body: { cloudflareError: 1033 } };
304 }),
305 (_pid, stillDead) =>
306 Effect.gen(function* () {
307 yield* Deferred.succeed(restartRequested, undefined);
308 yield* Deferred.await(releaseRestart);
309 const accepted = yield* stillDead;
310 yield* Queue.offer(guardChecks, accepted);
311 return accepted;
312 }),
313 );
314 yield* Effect.gen(function* () {
315 const reachability = yield* ConnectReachability.ConnectReachability;
316 yield* reachability.check;
317 yield* TestClock.adjust(Duration.seconds(119));
318
319 status = 200;
320 const healthy = yield* Effect.forkChild(reachability.check);
321 yield* Deferred.await(healthyRequested);
322 status = 530;
323 yield* TestClock.adjust(Duration.seconds(1));
324 yield* Deferred.await(restartRequested);
325
326 yield* Deferred.succeed(healthyAnswer, undefined);
327 expect(yield* Fiber.join(healthy)).toMatchObject({ status: "reachable" });
328 yield* Deferred.succeed(releaseRestart, undefined);
329 expect(yield* Queue.take(guardChecks)).toBe(false);
330
331 yield* reachability.check;
332 yield* TestClock.adjust(Duration.minutes(1));
333 expect(yield* Queue.size(guardChecks)).toBe(0);
334 yield* TestClock.adjust(Duration.minutes(1));
335 expect(yield* Queue.take(guardChecks)).toBe(true);
336 }).pipe(Effect.provide(layer));
337 }),
338 );
339
340 it.effect("drops the confirming check of a streak that already ended", () =>
341 Effect.gen(function* () {
342 using _connect = mockEdgeConnect();
343 const restarts = yield* Queue.unbounded<number>();
344 let status = 530;
345 let requests = 0;
346 const layer = reachabilityLayer(
347 Effect.sync(() => {
348 requests += 1;
349 return { status, body: { cloudflareError: 1033 } };
350 }),
351 (pid, stillDead) =>
352 stillDead.pipe(Effect.tap((dead) => (dead ? Queue.offer(restarts, pid) : Effect.void))),
353 );
354 yield* Effect.gen(function* () {
355 const reachability = yield* ConnectReachability.ConnectReachability;
356 yield* reachability.check;
357 yield* TestClock.adjust(Duration.minutes(1));
358 status = 200;
359 yield* reachability.check;
360 status = 530;
361 yield* reachability.check;
362
363 const before = requests;
364 yield* TestClock.adjust(Duration.minutes(1));
365 expect(requests).toBe(before);
366 yield* TestClock.adjust(Duration.minutes(1));
367 expect(yield* Queue.take(restarts)).toBe(connected.pid);
368 }).pipe(Effect.provide(layer));
369 }),
370 );
371
372 it.effect("keeps a 530 whose error body never finishes", () =>
373 Effect.gen(function* () {
374 using _connect = mockEdgeConnect();
375 let markBodyRead = () => {};
376 const bodyRead = new Promise<void>((resolve) => {
377 markBodyRead = resolve;
378 });
379 const layer = reachabilityLayer(
380 Effect.sync(() => ({
381 status: 530,
382 body: new ReadableStream({
383 pull: () => {
384 markBodyRead();
385 return new Promise<void>(() => {});
386 },
387 }),
388 })),
389 () => Effect.succeed(false),
390 );
391 yield* Effect.gen(function* () {
392 const reachability = yield* ConnectReachability.ConnectReachability;
393 const check = yield* Effect.forkChild(reachability.check);
394 yield* Effect.promise(() => bodyRead);
395 yield* TestClock.adjust(Duration.seconds(2));
396 expect(yield* Fiber.join(check)).toMatchObject({ cause: "no_connector" });
397 }).pipe(Effect.provide(layer));
398 }),
399 );
400});
401
402// undici wraps getaddrinfo's error in `TypeError: fetch failed`. glibc behind
403// systemd-resolved can report an NXDOMAIN as EBUSY rather than ENOTFOUND.
404const lookupFailed = (code: string) =>
405 Effect.fail(
406 new HttpClientError.HttpClientError({
407 reason: new HttpClientError.TransportError({
408 request: HttpClientRequest.get("https://env.example.test"),
409 cause: new TypeError("fetch failed", {
410 cause: Object.assign(new Error(`getaddrinfo ${code} env.example.test`), {
411 code,
412 syscall: "getaddrinfo",
413 hostname: "env.example.test",
414 }),
415 }),
416 }),
417 }),
418 );
419
420describe("ConnectReachability DNS failures", () => {
421 it.effect("reports a getaddrinfo EBUSY as a DNS failure", () =>
422 Effect.gen(function* () {
423 using _connect = mockEdgeConnect();
424 const layer = reachabilityLayer(lookupFailed("EBUSY"), () => Effect.succeed(false));
425 const result = yield* ConnectReachability.ConnectReachability.use(
426 (reachability) => reachability.check,
427 ).pipe(Effect.provide(layer));
428 expect(result).toMatchObject({ status: "unreachable", cause: "dns_failed" });
429 }),
430 );
431
432 // A local "not found" cached before the relay published the record looks like a missing
433 // record. Public DNS tells them apart.
434 it.effect("says whether the name exists in public DNS", () =>
435 Effect.gen(function* () {
436 using _connect = mockEdgeConnect();
437 for (const [lookupCode, dnsStatus, reason] of [
438 ["ENOTFOUND", 0, "old cached answer"],
439 ["ENOTFOUND", 3, "missing from public DNS"],
440 // The local resolver did not answer, so nothing it cached is to blame.
441 ["EAI_AGAIN", 0, "does not resolve from this machine"],
442 ] as const) {
443 const layer = reachabilityLayer(
444 (request) =>
445 request.url.startsWith("https://1.1.1.1/dns-query")
446 ? Effect.succeed({ status: 200, body: JSON.stringify({ Status: dnsStatus }) })
447 : lookupFailed(lookupCode),
448 () => Effect.succeed(false),
449 );
450 const result = yield* ConnectReachability.ConnectReachability.use(
451 (reachability) => reachability.check,
452 ).pipe(Effect.provide(layer));
453 expect(result).toMatchObject({
454 cause: "dns_failed",
455 reason: expect.stringContaining(reason),
456 });
457 }
458 }),
459 );
460});
461
462describe("T3 Connect troubleshooting links", () => {
463 it("each section names a heading in the user guide", () => {
464 const guide = NodeFS.readFileSync(
465 new URL("../../../../docs/user/t3-connect-troubleshooting.md", import.meta.url),
466 "utf8",
467 );
468 // GitHub's heading anchors: lowercase, drop punctuation, spaces become hyphens.
469 const anchors = new Set(
470 [...guide.matchAll(/^#{2,3} (.+)$/gm)].map(([, heading]) =>
471 heading!
472 .toLowerCase()
473 .replace(/[^\p{L}\p{N} _-]/gu, "")
474 .replace(/ /g, "-"),
475 ),
476 );
477 for (const section of T3_CONNECT_TROUBLESHOOTING_SECTIONS) {
478 expect(anchors, section).toContain(section);
479 }
480 });
481});
482
483describe("ConnectReachability tailscale and edge probes", () => {
484 const exitNodeStatusJson = JSON.stringify({
485 ExitNodeStatus: { Online: true },
486 Peer: { peer1: { ExitNode: true, DNSName: "exit-box.tail.ts.net." } },
487 });
488 const exitNodeHint =
489 'Tailscale exit node "exit-box" is on. Traffic to Cloudflare goes through it.';
490 const tailscaleOnPath: SpawnExecutableResolver = (command) =>
491 command === "tailscale" ? "/usr/bin/tailscale" : undefined;
492
493 const countingSpawner = () => {
494 const counter = { spawns: 0 };
495 const spawner = ChildProcessSpawner.make(() => {
496 counter.spawns += 1;
497 return Effect.succeed(
498 ChildProcessSpawner.makeHandle({
499 pid: ChildProcessSpawner.ProcessId(1),
500 exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)),
501 isRunning: Effect.succeed(false),
502 kill: () => Effect.void,
503 unref: Effect.succeed(Effect.void),
504 stdin: Sink.drain,
505 stdout: Stream.make(new TextEncoder().encode(exitNodeStatusJson)),
506 stderr: Stream.empty,
507 all: Stream.empty,
508 getInputFd: () => Sink.drain,
509 getOutputFd: () => Stream.empty,
510 }),
511 );
512 });
513 return { counter, spawner };
514 };
515
516 const mockEdgeTimeout = () =>
517 vi.spyOn(NodeNet, "connect").mockImplementation(() => {
518 const socket = new NodeNet.Socket();
519 queueMicrotask(() => socket.emit("error", new Error("ETIMEDOUT")));
520 return socket;
521 });
522
523 const runCheck = (layer: ReturnType<typeof reachabilityLayer>) =>
524 ConnectReachability.ConnectReachability.use((reachability) => reachability.check).pipe(
525 Effect.provide(layer),
526 );
527 const noRestart = () => Effect.succeed(false);
528
529 it.effect("does not spawn tailscale when the CLI is not installed", () =>
530 Effect.gen(function* () {
531 using _connect = mockEdgeTimeout();
532 const { counter, spawner } = countingSpawner();
533 const result = yield* runCheck(
534 reachabilityLayer(Effect.succeed({ status: 200, body: "" }), noRestart, {
535 connector: notConnected,
536 spawner,
537 }),
538 );
539 expect(result).toMatchObject({
540 cause: "edge_unreachable",
541 hint: "A VPN, proxy, or firewall may block it.",
542 });
543 expect(counter.spawns).toBe(0);
544 }),
545 );
546
547 it.effect("names the exit node when the edge is unreachable", () =>
548 Effect.gen(function* () {
549 using _connect = mockEdgeTimeout();
550 const { counter, spawner } = countingSpawner();
551 const result = yield* runCheck(
552 reachabilityLayer(Effect.succeed({ status: 200, body: "" }), noRestart, {
553 connector: notConnected,
554 spawner,
555 resolveExecutable: tailscaleOnPath,
556 }),
557 );
558 expect(result).toMatchObject({ cause: "edge_unreachable", hint: exitNodeHint });
559 expect(counter.spawns).toBe(1);
560 }),
561 );
562
563 it.effect("skips the exit node lookup when the edge answers", () =>
564 Effect.gen(function* () {
565 using connectSpy = mockEdgeConnect();
566 const { counter, spawner } = countingSpawner();
567 const result = yield* runCheck(
568 reachabilityLayer(Effect.succeed({ status: 200, body: "" }), noRestart, {
569 connector: notConnected,
570 spawner,
571 resolveExecutable: tailscaleOnPath,
572 }),
573 );
574 expect(result).toMatchObject({ cause: "connector_not_ready" });
575 expect(connectSpy).toHaveBeenCalled();
576 expect(counter.spawns).toBe(0);
577 }),
578 );
579
580 it.effect.each([
581 [502, "", "origin_unreachable"],
582 [530, { cloudflareError: 1033 }, "no_connector"],
583 ] as const)("runs neither probe for HTTP %i", ([status, body, cause]) =>
584 Effect.gen(function* () {
585 using connectSpy = mockEdgeConnect();
586 const { counter, spawner } = countingSpawner();
587 const result = yield* runCheck(
588 reachabilityLayer(Effect.succeed({ status, body }), noRestart, {
589 spawner,
590 resolveExecutable: tailscaleOnPath,
591 }),
592 );
593 expect(result).toMatchObject({ cause });
594 expect(connectSpy).not.toHaveBeenCalled();
595 expect(counter.spawns).toBe(0);
596 }),
597 );
598
599 it.effect("reads only the exit node for a stale DNS answer", () =>
600 Effect.gen(function* () {
601 using connectSpy = mockEdgeConnect();
602 const { counter, spawner } = countingSpawner();
603 const result = yield* runCheck(
604 reachabilityLayer(
605 (request) =>
606 request.url.startsWith("https://1.1.1.1/dns-query")
607 ? Effect.succeed({ status: 200, body: JSON.stringify({ Status: 0 }) })
608 : lookupFailed("ENOTFOUND"),
609 noRestart,
610 { spawner, resolveExecutable: tailscaleOnPath },
611 ),
612 );
613 expect(result).toMatchObject({ cause: "dns_failed", hint: exitNodeHint });
614 expect(connectSpy).not.toHaveBeenCalled();
615 expect(counter.spawns).toBe(1);
616 }),
617 );
618});