mirror of
https://github.com/morluto/rea.git
synced 2026-11-10 00:36:35 +00:00
fix(javascript): preserve recovery acquisition and cancellation failures
This commit is contained in:
1 parent
cb689fae96
commit
e00b2eda0b
11 files changed
+191
-33
No files matched your search
@@ -123,11 +123,14 @@ describe("JavaScript recovery workflow", () => {
|
||||
const invalid = await service.recover({});
|
||||
if (invalid.ok) throw new Error("expected malformed input");
|
||||
expect(invalid.error._tag).toBe("AnalysisInputError");
|
||||
const cancelled = await service.recover(input, {
|
||||
signal: AbortSignal.abort(),
|
||||
});
|
||||
if (cancelled.ok) throw new Error("expected cancellation");
|
||||
expect(cancelled.error._tag).toBe("AnalysisCancelledError");
|
||||
for (const reason of [null, false, { request: "cancel recovery" }]) {
|
||||
const cancelled = await service.recover(input, {
|
||||
signal: AbortSignal.abort(reason),
|
||||
});
|
||||
if (cancelled.ok) throw new Error("expected cancellation");
|
||||
expect(cancelled.error._tag).toBe("AnalysisCancelledError");
|
||||
expect(cancelled.error.cause).toBe(reason);
|
||||
}
|
||||
});
|
||||
it("rejects additional_paths repeating path or each other", async () => {
|
||||
const service = new JavaScriptRecoveryService({
|
||||
|
||||
@@ -34,7 +34,9 @@ export class JavaScriptRecoveryService {
|
||||
options?: ExecutionOptions,
|
||||
): Promise<Result<Evidence, AnalysisError>> {
|
||||
if (options?.signal?.aborted === true)
|
||||
return err(new AnalysisCancelledError(OPERATION));
|
||||
return err(
|
||||
new AnalysisCancelledError(OPERATION, { cause: options.signal.reason }),
|
||||
);
|
||||
const parsed = javascriptRecoveryInputSchema.safeParse(input);
|
||||
if (!parsed.success)
|
||||
return err(
|
||||
|
||||
Reference in new issue
Block a user