Skip to content

tokio::spawn at ~30 sites swallows panics — no JoinHandle awaited, supervisor never notified #3740

Description

@houko

Location

  • crates/librefang-kernel/src/kernel/mod.rs:5458, 5497, 6292, 10970, 11985, 11620, 11644, 11703, 11942 and ~20 more sites

Problem
Many tokio::spawn(async move { ... }) invocations either drop the JoinHandle or hold but never await it. Tokio's default behavior: panics propagate only to the JoinHandle — without an awaiter, panics vanish, no log. supervisor.record_panic exists but is only called in the explicit Err(e) branch — it doesn't catch real Rust panics (unwrap on None, slice out of bounds, serialization failures, etc.).

Impact
A tool invocation panics on a corner-case input; that agent's loop dies silently, no alert. A channel-bridge spawn panics; that bridge stops working until daemon restart; no diagnostics.

Fix
Wrap with AssertUnwindSafe(...).catch_unwind() and on Err call supervisor.record_panic(name, info). Centralize via a kernel.spawn_supervised(name, fut) helper used everywhere.


Filed via automated multi-perspective audit (security / concurrency / architecture / error-handling / frontend / performance subagents). Curated against #3359#3409 to avoid duplicates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/kernelCore kernel (scheduling, RBAC, workflows)bugSomething isn't workingneeds-triageAuto-applied when the issue title/body matched no area label — needs maintainer reviewseverity/mediumBug or limitation with workaround / partial impact

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions