dd5c329bc3
- Added `markHandled` helper to prevent unhandled promise rejections in fire-and-forget browser tasks. - Integrated `postmortem.markExpectedCleanupError` to distinguish between expected teardown aborts and actual runtime failures. - Updated `runCmuxCode` and `WorkerCore` to propagate abort reasons via `ToolAbortError` cause chains. - Modified `tab-protocol` and supervisor logic to signal expected cleanup states during tab release. - Added test coverage for `ToolAbortError` wrapping and cause preservation.
23 lines
766 B
TypeScript
23 lines
766 B
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { postmortem } from "@oh-my-pi/pi-utils";
|
|
import { ToolAbortError, throwIfAborted } from "../../src/tools/tool-errors";
|
|
|
|
describe("tool abort errors", () => {
|
|
it("wraps non-ToolAbortError abort reasons as ToolAbortError while preserving marked cause chains", () => {
|
|
const controller = new AbortController();
|
|
const reason = postmortem.markExpectedCleanupError(new Error("browser run ended"));
|
|
controller.abort(reason);
|
|
|
|
let caught: unknown;
|
|
try {
|
|
throwIfAborted(controller.signal);
|
|
} catch (error) {
|
|
caught = error;
|
|
}
|
|
|
|
expect(caught).toBeInstanceOf(ToolAbortError);
|
|
expect((caught as Error).cause).toBe(reason);
|
|
expect(postmortem.isExpectedCleanupError(caught)).toBe(true);
|
|
});
|
|
});
|