{"record":{"id":"87308071719af4d0","repo":"libnyanpasu/clash-nyanpasu","slug":"should-never-drop-oneshot-tx","errorCode":null,"errorMessage":"should never drop oneshot tx","messagePattern":"should never drop oneshot tx","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"backend/boa_utils/src/module/http.rs","lineNumber":177,"sourceCode":"\n                    let mime = response\n                        .headers()\n                        .get(reqwest::header::CONTENT_TYPE)\n                        .and_then(|v| v.to_str().ok())\n                        .map(|v| v.to_string())\n                        .unwrap_or(mime::TEXT_PLAIN.to_string());\n                    let body = response.text().await?;\n\n                    log::debug!(\"finished fetching `{fetcher_url}`\");\n                    Ok(CachedItem {\n                        mime,\n                        content: body,\n                    })\n                }\n                .await;\n                let _ = tx.send(result);\n            });\n            rx.await.expect(\"should never drop oneshot tx\")\n        };\n\n        if let Ok(item) = &item {\n            match postcard::to_stdvec(&item) {\n                Ok(item) => {\n                    if let Err(err) = async_fs::write(&cache_path, &item).await {\n                        log::error!(\n                            \"failed to write cache for `{url}`; path: `{}`. error: `{}`\",\n                            cache_path.display(),\n                            err\n                        );\n                    }\n                }\n                Err(err) => {\n                    log::error!(\"failed to serialize content: {err}\");\n                }\n            }\n        }","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/boa_utils/src/module/http.rs#L159-L195","documentation":"`load_imported_module` fetches module content over an internal oneshot channel spawned on an async runtime and does `rx.await.expect(\"should never drop oneshot tx\")`. If the spawned task panics or the runtime is shut down before sending, the sender drops and the expect panics with this message.","triggerScenarios":"Calling `load_imported_module` when the spawned fetch task panics (e.g. the invalid-url panic in the same flow), the async runtime has been dropped, or the task is cancelled before `tx.send` runs.","commonSituations":"Runtime shutdown during app exit while a module import is in flight; a panic inside the spawned task (like error 238) dropping the oneshot sender; blocking the runtime so the task is aborted.","solutions":["Replace `.expect` with graceful handling: `rx.await.unwrap_or_else(|_| Err(...))` returning a JS error.","Ensure the async runtime outlives all module-loading operations.","Fix the root panic in the spawned task (often the invalid-url panic) so the sender always sends.","Wrap module loading so runtime shutdown doesn't race pending imports."],"exampleFix":"// before\nrx.await.expect(\"should never drop oneshot tx\")\n// after\nrx.await.map_err(|_| JsNativeError::typ().with_message(\"module loader task dropped\"))?","handlingStrategy":"try-catch","validationCode":"// cannot pre-validate; ensure runtime is alive before loading modules\nif (!runtimeAlive()) throw new Error('async runtime unavailable; cannot load modules');","typeGuard":null,"tryCatchPattern":"// Rust side: replace expect with graceful JS error\nrx.await.map_err(|_| JsNativeError::typ().with_message(\"module loader task dropped\"))?","preventionTips":["Keep the async runtime alive for the duration of module loading","Fix panics inside the spawned fetch task so the oneshot sender always sends","Avoid runtime shutdown racing in-flight module imports"],"tags":["javascript","boa","async","oneshot-channel","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}