test: require logging async callbacks · openclaw/openclaw@7011bbb
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -324,7 +324,7 @@ describe("stuck session recovery", () => {
|
324 | 324 | }); |
325 | 325 | |
326 | 326 | it("coalesces duplicate recovery attempts for the same session", async () => { |
327 | | -let resolveWait!: (value: boolean) => void; |
| 327 | +let resolveWait: ((value: boolean) => void) | undefined; |
328 | 328 | const waitPromise = new Promise<boolean>((resolve) => { |
329 | 329 | resolveWait = resolve; |
330 | 330 | }); |
@@ -346,6 +346,9 @@ describe("stuck session recovery", () => {
|
346 | 346 | }); |
347 | 347 | |
348 | 348 | expect(mocks.abortEmbeddedPiRun).toHaveBeenCalledTimes(1); |
| 349 | +if (!resolveWait) { |
| 350 | +throw new Error("Expected diagnostic recovery wait resolver to be initialized"); |
| 351 | +} |
349 | 352 | resolveWait(true); |
350 | 353 | await first; |
351 | 354 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -903,14 +903,18 @@ describe("stuck session diagnostics threshold", () => {
|
903 | 903 | const warnSpy = vi.spyOn(diagnosticLogger, "warn").mockImplementation(() => undefined); |
904 | 904 | const events: DiagnosticEventPayload[] = []; |
905 | 905 | const unsubscribe = onDiagnosticEvent((event) => events.push(event)); |
906 | | -let finishPhase!: () => void; |
| 906 | +let finishPhase: (() => void) | undefined; |
907 | 907 | const phase = withDiagnosticPhase( |
908 | 908 | "startup.plugins.load", |
909 | 909 | () => |
910 | 910 | new Promise<void>((resolve) => { |
911 | 911 | finishPhase = resolve; |
912 | 912 | }), |
913 | 913 | ); |
| 914 | +if (!finishPhase) { |
| 915 | +throw new Error("Expected diagnostic phase finish callback to be initialized"); |
| 916 | +} |
| 917 | +const completePhase = finishPhase; |
914 | 918 | |
915 | 919 | try { |
916 | 920 | startDiagnosticHeartbeat( |
@@ -933,7 +937,7 @@ describe("stuck session diagnostics threshold", () => {
|
933 | 937 | logMessageQueued({ sessionId: "s1", sessionKey: "main", source: "telegram" }); |
934 | 938 | vi.advanceTimersByTime(30_000); |
935 | 939 | } finally { |
936 | | -finishPhase(); |
| 940 | +completePhase(); |
937 | 941 | await phase; |
938 | 942 | unsubscribe(); |
939 | 943 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。