{"record":{"id":"fba65545d4173b5b","repo":"denoland/deno","slug":"esbuild-exited-before-the-rebuild-completed","errorCode":null,"errorMessage":"esbuild exited before the rebuild completed","messagePattern":"esbuild exited before the rebuild completed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/bundle/mod.rs","lineNumber":1185,"sourceCode":"\n    Ok(response)\n  }\n\n  async fn rebuild(&mut self) -> Result<BuildResponse, AnyError> {\n    match self.mode {\n      BundlingMode::OneShot => {\n        panic!(\"rebuild not supported for one-shot mode\")\n      }\n      BundlingMode::Watch => {\n        log::trace!(\"sending rebuild request\");\n        let _response = self\n          .client\n          .send_rebuild_request(0)\n          .await\n          .context(\"failed to send rebuild request to esbuild\")?\n          .map_err(|e| message_to_error(&e, &self.cwd))?;\n        let response = self.on_end_rx.recv().await.ok_or_else(|| {\n          deno_core::anyhow::anyhow!(\n            \"esbuild exited before the rebuild completed\"\n          )\n        })?;\n        Ok(response.into())\n      }\n    }\n  }\n\n  async fn reload_specifiers(\n    &mut self,\n    changed_paths: &[PathBuf],\n  ) -> Result<(), AnyError> {\n    self.reload_html_entrypoints(changed_paths)?;\n    self.plugin_handler.reload_specifiers(changed_paths).await?;\n    Ok(())\n  }\n\n  fn reload_html_entrypoints(","sourceCodeStart":1167,"sourceCodeEnd":1203,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/bundle/mod.rs#L1167-L1203","documentation":"In `deno bundle --watch`, after sending a rebuild request Deno waits on esbuild's rebuild-complete event over a channel. If that channel closes instead of yielding a response, the esbuild child process exited (crashed or was killed) before finishing the rebuild, and watch mode surfaces this error.","triggerScenarios":"A watch-mode rebuild during which the esbuild service dies: OOM kill, manual kill of the esbuild process, an esbuild panic on pathological input, or system shutdown mid-rebuild.","commonSituations":"Memory-constrained dev machines or CI where esbuild gets OOM-killed on large rebuilds; stray process cleanup scripts killing esbuild children.","solutions":["Re-run the bundle — the next start respawns the esbuild service cleanly","Check `dmesg`/journalctl for an OOM kill of esbuild; free memory or split the bundle to reduce peak usage","Update deno (bundled esbuild fixes land often); if esbuild panicked, capture its stderr and report the repro"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"In watch/build scripts, catch this error, treat the esbuild service as dead, and restart the bundling task (bounded retries with backoff) rather than propagating immediately.","preventionTips":["Give dev machines and CI enough memory for large incremental rebuilds","Avoid killing esbuild children with blanket cleanup scripts","Update deno regularly to pick up bundled esbuild fixes"],"tags":["bundle","watch-mode","esbuild","process-crash"],"backgroundTag":"child-process-exited-unexpectedly","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}