Files
rea/src/hopper/HopperSocketConnection.test.ts
T
4a7a4b5744 fix(hopper): preserve caller abort reasons on cancellation (#5780)
* fix(hopper): preserve caller abort reasons on cancellation

Hopper cancellation dropped the caller's abort reason, and the typed
error treated an explicit undefined cause as omission. Retain the exact
reason at the request queue, startup, socket, and launcher boundaries.

Co-authored-by: morluto <morluto@users.noreply.github.com>

* style(hopper): format launcher cancellation return

oxfmt rejects the wrapped abort return in HopperApplicationLauncher.

Co-authored-by: morluto <morluto@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-10-21 13:53:02 +08:00

23 lines
787 B
TypeScript

import { tmpdir } from "node:os";
import { join } from "node:path";
import { expect, it } from "vitest";
import { HopperCancelledError } from "../domain/hopperErrors.js";
import { connectHopperSocketOnce } from "./HopperSocketConnection.js";
it("retains the caller abort reason when the socket signal is already aborted", async () => {
const reason = { source: "caller", opaque: 7 };
const controller = new AbortController();
controller.abort(reason);
const result = await connectHopperSocketOnce(
join(tmpdir(), "rea-hopper-cancelled.sock"),
controller.signal,
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("Expected cancellation");
expect(result.error).toBeInstanceOf(HopperCancelledError);
expect(result.error.cause).toBe(reason);
});