{"record":{"id":"161e62a80b59b37f","repo":"swc-project/swc","slug":"deno-bundle-failed-with-status-code","errorCode":null,"errorMessage":"`deno bundle` failed with status code {}","messagePattern":"`deno bundle` failed with status code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/dbg-swc/src/bundle.rs","lineNumber":22,"sourceCode":"};\n\nuse anyhow::{bail, Context, Result};\nuse swc_common::{FileName, SourceMap};\n\nuse crate::util::{parse_js, wrap_task, ModuleRecord};\n\npub fn bundle(cm: Arc<SourceMap>, entry_url: &str) -> Result<ModuleRecord> {\n    wrap_task(|| {\n        let mut cmd = Command::new(\"deno\");\n        cmd.arg(\"bundle\");\n        cmd.arg(entry_url);\n\n        cmd.stderr(Stdio::inherit());\n\n        let output = cmd.output().context(\"failed to invoke `deno bundle`\")?;\n\n        if !output.status.success() {\n            bail!(\"`deno bundle` failed with status code {}\", output.status);\n        }\n\n        let code =\n            String::from_utf8(output.stdout).context(\"deno bundle emitted non-utf8 output\")?;\n\n        let fm = cm.new_source_file(FileName::Anon.into(), code);\n        parse_js(fm).context(\"failed to parse js filed emitted by `deno bundle`\")\n    })\n    .with_context(|| format!(\"failed to bundle `{entry_url}`\"))\n}\n","sourceCodeStart":4,"sourceCodeEnd":33,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/dbg-swc/src/bundle.rs#L4-L33","documentation":"dbg-swc's bundle helper shells out to the deno CLI ('deno bundle <entry_url>'), inheriting stderr so deno's own error output reaches the terminal, and bails with the child's status code when it exits non-zero. The failure comes from deno, not from SWC: module download failures, an unreachable or mistyped entry URL, compile errors in the dependency graph, or a deno binary that no longer supports the bundle subcommand (it was removed in Deno 2).","triggerScenarios":"Running the dbg-swc bundle command for an entry URL deno cannot fetch or compile; the message shows the raw exit status (deno uses 101 for uncaught errors, 1 for general failure).","commonSituations":"Offline or proxied sandboxes where deno cannot download remote modules; environments that upgraded to Deno 2.x where 'deno bundle' no longer exists; remote specifiers behind auth (missing DENO_AUTH_TOKENS); typos in the entry URL.","solutions":["Run 'deno bundle <entry_url>' manually in the same shell - deno's stderr shows the true reason","Check 'deno --version': 'deno bundle' was removed in Deno 2; pin Deno 1.x for this helper","Ensure network/proxy access and DENO_AUTH_TOKENS for private modules, or vendor dependencies locally","Verify the entry URL resolves (curl it) before invoking dbg-swc"],"exampleFix":"# before: system deno is 2.x, `deno bundle` is gone\n$ deno --version\ndeno 2.0.0\n\n# after: pin a 1.x deno for this workflow\n$ asdf install deno 1.46.3\n$ asdf local deno 1.46.3\n$ deno bundle ./entry.ts   # works, dbg-swc bundle proceeds","handlingStrategy":"retry","validationCode":"use std::process::Command;\n\nfn deno_available() -> bool {\n    Command::new(\"deno\")\n        .arg(\"--version\")\n        .output()\n        .map(|o| o.status.success())\n        .unwrap_or(false)\n}\n\nfn entry_reachable(url: &str) -> bool {\n    // cheap check before shelling out\n    url::Url::parse(url).is_ok()\n}","typeGuard":null,"tryCatchPattern":"fn bundle_retry(cm: Arc<SourceMap>, url: &str) -> Result<ModuleRecord> {\n    let mut last = None;\n    for attempt in 0..3 {\n        match bundle(cm.clone(), url) {\n            Ok(r) => return Ok(r),\n            Err(e) => {\n                let msg = format!(\"{e:#}\");\n                if msg.contains(\"failed to invoke\") || msg.contains(\"removed\") {\n                    return Err(e); // binary missing / unsupported subcommand: do not retry\n                }\n                eprintln!(\"deno bundle attempt {} failed: {}\", attempt + 1, msg);\n                last = Some(e);\n            }\n        }\n    }\n    Err(last.expect(\"at least one attempt\"))\n}","preventionTips":["Pin Deno 1.x in CI - 'deno bundle' does not exist in Deno 2","Vendor or cache remote dependencies (DENO_DIR, lockfile) so bundles work offline","Verify the entry URL with a plain fetch/curl before invoking dbg-swc"],"tags":["dbg-swc","deno","subprocess","bundle"],"backgroundTag":"build-tool-exit-nonzero","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}