{"record":{"id":"5a4b536dcf31980f","repo":"clockworklabs/SpacetimeDB","slug":"tsc-exited-with-status","errorCode":null,"errorMessage":"tsc exited with {status}","messagePattern":"tsc exited with (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/javascript.rs","lineNumber":64,"sourceCode":"\n    let mut tsc_path = cwd.join(\"node_modules/.bin/tsc\");\n    if cfg!(windows) {\n        tsc_path.set_extension(\"cmd\");\n    }\n    if tsc_path.exists() {\n        let status = std::process::Command::new(tsc_path)\n            .arg(\"--noEmit\")\n            .current_dir(&cwd)\n            .status()\n            .context(\"Failed to execute tsc\")?;\n        if !status.success() {\n            if let Some(code) = status.code()\n                && let Ok(code) = u8::try_from(code).map(ExitCode::from)\n            {\n                anyhow::bail!(ExitWithCode(code));\n            }\n            // For an abnormal exit, show the details of the status.\n            anyhow::bail!(\"tsc exited with {status}\");\n        }\n    } else {\n        eprintln!(\n            \"tsc not found in node_modules. Make sure you have the `typescript` package \\\n             as a dev-dependency and that your dependencies are installed.\"\n        )\n    }\n\n    let mut bundler = Bundler::new(BundlerOptions {\n        input: Some(vec![\"./src/index.ts\".to_string().into()]),\n        cwd: Some(cwd.clone()),\n        sourcemap: Some(SourceMapType::Inline),\n        external: Some(rolldown::IsExternal::StringOrRegex(vec![\n            // Mark the bindings as external so we don't get a warning.\n            StringOrRegex::Regex(HybridRegex::Optimize(Regex::new(\"spacetime:sys.*\").unwrap())),\n        ])),\n        platform: Some(rolldown::Platform::Browser), // Browser is the correct choice here because it doesn't inject Node.js polyfills.\n        shim_missing_exports: Some(false),","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/javascript.rs#L46-L82","documentation":"For JavaScript modules the CLI runs the project-local node_modules/.bin/tsc --noEmit before bundling. Ordinary type errors exit with a small code which the CLI propagates via a special ExitWithCode error to preserve tsc's exit status. This message is reserved for abnormal exits -- no usable exit code, i.e. tsc was killed by a signal (the {status} renders e.g. 'signal: 9 (SIGKILL)') or crashed, rather than merely reporting diagnostics.","triggerScenarios":"`spacetime build`/`spacetime publish` on a JS module where the tsc process is killed by the OS OOM killer (memory-limited CI containers), segfaults, or exits with an out-of-range code.","commonSituations":"CI containers with low memory limits compiling large TypeScript projects; corrupted node_modules after a node version change; node/tsc version mismatches.","solutions":["Run the identical check yourself in the project dir: ./node_modules/.bin/tsc --noEmit (or npx tsc --noEmit) and observe the crash.","If OOM: raise the container/CI memory limit or the node heap, e.g. NODE_OPTIONS=--max-old-space-size=4096.","Reinstall dependencies (rm -rf node_modules && npm install) after any node upgrade.","Note: plain type errors take a different path (tsc prints diagnostics and the CLI exits with tsc's code) -- fix those normally."],"exampleFix":"# before: CI job with 512MB gets tsc OOM-killed\nspacetime build\n# after\ndocker run -e NODE_OPTIONS=--max-old-space-size=4096 -m 4g ... spacetime build","handlingStrategy":"try-catch","validationCode":"# Run the exact pre-build check in the same resource-constrained environment\n( cd \"$PROJECT\" && ./node_modules/.bin/tsc --noEmit ) || exit 1\nspacetime build","typeGuard":null,"tryCatchPattern":"out=$(spacetime build 2>&1); status=$?\nif [ $status -ne 0 ] && echo \"$out\" | grep -q \"tsc exited with signal\"; then\n  echo \"tsc was killed (likely OOM)\" >&2; NODE_OPTIONS=--max-old-space-size=4096 spacetime build\nfi","preventionTips":["Give CI containers enough memory for tsc on large TS projects; raise node heap via NODE_OPTIONS.","Reinstall node_modules after node version upgrades.","Run `tsc --noEmit` as its own CI step so crashes are attributable before spacetime enters the picture."],"tags":["javascript","typescript","tsc","out-of-memory","crash"],"backgroundTag":"compiler-crashed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}