Recovery Boundary
resumable recovery inside a guard boundary
function* publishListing() {
yield* guard(
function* reviewListing() {
const approval = yield* resumable(
function* scanPhotos() {
yield* sleep(1000);
throw new Error("scanner offline");
},
);
yield* recordApproval(approval);
},
function* approveManually(error) {
yield* sleep(1000);
return [true, `manual approval: ${error.kind}`] as const;
},
);
} publishListing enters guard to run reviewListing.
reviewListing starts scanPhotos through resumable and waits for the value from resumable.
After scanPhotos fails inside its child scope, guard lets approveManually handle the failure in the same boundary.
approveManually returns approval, and resumable gives that value back to reviewListing's wait point.