Issue #2884: A read of a task’s value whose failure an earlier mention received throws task::Abandoned (ADR-async-v7 D43)

Open and answer this issue on GitHub.

ready, bugs, queued · opened 2026-11-28 · updated 2026-11-29 · 0 comments

Filed by the driver from the Found: of the run of issue-2595 (#2595) (owner, 2026-11-06).

Found

A task that catches a failure of a pending value the main line reads too makes the program exit 101 with nothing printed. ADR-async-v6 D8/D41 did not say what the main line’s read throws once the task has received the error (task::Abandoned, or the error again). Suspected: crates/nikaia-std/src/task/group.rs Read::cancelled_waiter resume_unwind, reached from the main line’s during(__task_N.join()).

Probe on develop cd0f9070 (2026-11-29), today a different failure, an internal error:

struct Bad {}
impl Error for Bad { fn message(ref self) -> String { return "bad" } }
fn load(n: i64) -> i64 throws {
    if n > 5 { throw Bad {} }
    return n * 2
}
fn f(n: i64) -> i64 { return n + 1 }
fn run(n: i64) throws {
    let a = async load(n)
    let b = async f(a) catch { println(f"b's fallback: {error}"); -1 }
    println(f"a is {a}")
    println(f"b is {b}")
}
fn main() throws {
    run(1)
    run(9) catch { println(f"run failed: {error}") }
    println("end")
}
error[NK1343]: ... Rustc output: cannot find value `a` in this scope.   (exit 101)

Decision (supervisor, 2026-11-29)

Decided under docs/supervisor.md, Language decisions, as obvious by D8 and D41. Where a fails, the first mention of a in written order receives its error (D8), here b’s task, whose fallback handles it. A later read of a itself has no value: it throws task::Abandoned, which says that a failed and where its error was received and carries that error as its cause, as the read of a cancelled waiter does (D41, owner). It is not a’s error again (one receiver: no handler runs twice), and it is not a panic (ADR-346 D1: every task error has a receiver, none dropped without a trace).

To build

  1. Fix the NK1343 above: async f(a) catch { … } with a a pending value of the same function lowers to Rust that names a where it is not in scope.
  2. Runtime: a read of a after the mention that received its failure throws task::Abandoned with a’s error as its cause (ADR-async-v7 D43), not a resume_unwind (task/group.rs, Read::cancelled_waiter and the main line’s read).
  3. Checker: the read of a counts task::Abandoned as a thrown error where an earlier mention can receive a’s failure (D43), as D41 does for a waiter.
  4. Test tests/compiler/tests/async_read_after_failure_received_is_abandoned.nika with the probe above; .stdout: a is 2, b is 3, b's fallback: bad, then run failed: … naming task::Abandoned and bad, then end.
  5. ADR index: Built column of async-v7 names D43 as built.

Done when

The probe prints the .stdout of step 4 and exits 0, and that test is green in nikaia test.

Back to Open Issues