{"record":{"id":"6ea0465beaf1b454","repo":"rolldown/rolldown","slug":"moduleloader-failed-to-send-build-errors-main-t","errorCode":null,"errorMessage":"ModuleLoader: failed to send build errors - main thread terminated while processing module errors","messagePattern":"ModuleLoader: failed to send build errors - main thread terminated while processing module errors","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/rolldown/src/module_loader/module_task.rs","lineNumber":87,"sourceCode":"      module_idx: idx,\n      resolved_id,\n      owner,\n      is_user_defined_entry,\n      asserted_module_type: assert_module_type,\n      flat_options,\n      magic_string_tx,\n    }\n  }\n\n  #[tracing::instrument(name=\"NormalModuleTask::run\", level = \"trace\", skip_all, fields(module_id = %self.resolved_id.id))]\n  pub async fn run(mut self) {\n    if let Err(errs) = self.run_inner().await {\n      self.ctx.plugin_driver.mark_context_load_modules_loaded(self.resolved_id.id.clone());\n      self\n        .ctx\n        .tx\n        .send(ModuleLoaderMsg::BuildErrors(errs.into_vec().into_boxed_slice()))\n        .expect(\"ModuleLoader: failed to send build errors - main thread terminated while processing module errors\");\n    }\n  }\n\n  async fn run_inner(&mut self) -> BuildResult<()> {\n    let id = self.resolved_id.id.clone();\n\n    self.ctx.plugin_driver.set_module_info(\n      &id,\n      Arc::new(ModuleInfo {\n        code: None,\n        id: id.clone(),\n        is_entry: self.is_user_defined_entry,\n        importers: FxIndexSet::default(),\n        dynamic_importers: FxIndexSet::default(),\n        imported_ids: FxIndexSet::default(),\n        dynamically_imported_ids: FxIndexSet::default(),\n        exports: vec![],\n        input_format: ExportsKind::None,","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/rolldown/rolldown/blob/91b44b9d7bcfb5725533478e044e3891a251b2c5/crates/rolldown/src/module_loader/module_task.rs#L69-L105","documentation":"Like the external variant, a normal module task that fails sends `BuildErrors` to the loader main thread via a channel. The `expect` panics if the receiver is gone — the main thread terminated (panic, abort, cancellation) while the module task was still reporting its errors.","triggerScenarios":"Main module-loader loop drops `rx` before all module tasks finish — caused by a fatal error elsewhere in the build, a panic in the loader, or cancellation of the build future.","commonSituations":"Another module's hard failure shuts down the loader while siblings are still erroring; user-initiated cancellation; plugins panicking in the main thread.","solutions":["Find and fix the primary/first error in the logs — this panic is a secondary symptom","Avoid cancelling the build mid-flight; let it emit its errors normally","Report to rolldown if the main thread dies without emitting a primary error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await rolldown(input);\n} catch (e) {\n  // treat this as secondary; find the first real module error in stderr\n  console.error('primary error:', e);\n}","preventionTips":["Resolve the first-reported module error; the channel panic follows it","Let builds run to completion rather than cancelling on the first failure","Keep transform/load hooks free of throws that can kill the main thread"],"tags":["async","channel","concurrency","internal"],"backgroundTag":"broken-pipe","analyzedSha":"91b44b9d7bcfb5725533478e044e3891a251b2c5","analyzedAt":"2026-09-07T16:04:13.504Z","contentChangedAt":"2026-09-07T16:04:13.504Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}