Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/delimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ export class Delimiter<T>
if (this.finalized) {
return;
}
this.outcome = outcome;
this.outcome =
(this.outcome && this.outcome.exists && !this.outcome.value.ok)
? this.outcome
: outcome;
this.level++;
if (!this.routine) {
this.finalized = true;
this.future.resolve(outcome);
this.future.resolve(this.outcome);
} else {
this.routine.return(Ok(outcome));
this.routine.return(Ok(this.outcome));
}
}

Expand Down
17 changes: 9 additions & 8 deletions test/scoped.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { box } from "../lib/box.ts";
import {
createContext,
resource,
Expand Down Expand Up @@ -157,21 +158,21 @@ describe("scoped", () => {
}));
});

it.skip("throws errors at the correct point when there are multiple nested scopes", async () => {
it("throws errors at the correct point when there are multiple nested scopes", async () => {
let task = run(function* () {
return yield* scoped(function* () {
yield* spawn(function* () {
yield* sleep(1);
throw new Error("boom!");
});

try {
return yield* scoped(function* () {
yield* suspend();
});
} catch (error) {
return error;
}
yield* box(() =>
scoped(function* () {
yield* scoped(function* () {
yield* suspend();
});
})
);
});
});

Expand Down
1 change: 0 additions & 1 deletion test/spawn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ describe("spawn", () => {

await expect(root.halt()).rejects.toHaveProperty("message", "moo");
await expect(child!.halt()).rejects.toHaveProperty("message", "moo");
await expect(root.halt()).rejects.toHaveProperty("message", "moo");
});

it("halts when child finishes during asynchronous halt", async () => {
Expand Down
Loading