clockworklabs/SpacetimeDB · error · anyhow::Error

tsc exited with

Error message

tsc exited with {status}

What it means

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.

Solutions

  1. Run the identical check yourself in the project dir: ./node_modules/.bin/tsc --noEmit (or npx tsc --noEmit) and observe the crash.
  2. If OOM: raise the container/CI memory limit or the node heap, e.g. NODE_OPTIONS=--max-old-space-size=4096.
  3. Reinstall dependencies (rm -rf node_modules && npm install) after any node upgrade.
  4. Note: plain type errors take a different path (tsc prints diagnostics and the CLI exits with tsc's code) -- fix those normally.

Example fix

# before: CI job with 512MB gets tsc OOM-killed
spacetime build
# after
docker run -e NODE_OPTIONS=--max-old-space-size=4096 -m 4g ... spacetime build
Defensive patterns

Strategy: try-catch

Validate before calling

# Run the exact pre-build check in the same resource-constrained environment
( cd "$PROJECT" && ./node_modules/.bin/tsc --noEmit ) || exit 1
spacetime build

Try / catch

out=$(spacetime build 2>&1); status=$?
if [ $status -ne 0 ] && echo "$out" | grep -q "tsc exited with signal"; then
  echo "tsc was killed (likely OOM)" >&2; NODE_OPTIONS=--max-old-space-size=4096 spacetime build
fi

Prevention

When it happens

Trigger: `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.

Common situations: CI containers with low memory limits compiling large TypeScript projects; corrupted node_modules after a node version change; node/tsc version mismatches.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20). Data as JSON: /api/errors/5a4b536dcf31980f. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/tasks/javascript.rs:64

    let mut tsc_path = cwd.join("node_modules/.bin/tsc");
    if cfg!(windows) {
        tsc_path.set_extension("cmd");
    }
    if tsc_path.exists() {
        let status = std::process::Command::new(tsc_path)
            .arg("--noEmit")
            .current_dir(&cwd)
            .status()
            .context("Failed to execute tsc")?;
        if !status.success() {
            if let Some(code) = status.code()
                && let Ok(code) = u8::try_from(code).map(ExitCode::from)
            {
                anyhow::bail!(ExitWithCode(code));
            }
            // For an abnormal exit, show the details of the status.
            anyhow::bail!("tsc exited with {status}");
        }
    } else {
        eprintln!(
            "tsc not found in node_modules. Make sure you have the `typescript` package \
             as a dev-dependency and that your dependencies are installed."
        )
    }

    let mut bundler = Bundler::new(BundlerOptions {
        input: Some(vec!["./src/index.ts".to_string().into()]),
        cwd: Some(cwd.clone()),
        sourcemap: Some(SourceMapType::Inline),
        external: Some(rolldown::IsExternal::StringOrRegex(vec![
            // Mark the bindings as external so we don't get a warning.
            StringOrRegex::Regex(HybridRegex::Optimize(Regex::new("spacetime:sys.*").unwrap())),
        ])),
        platform: Some(rolldown::Platform::Browser), // Browser is the correct choice here because it doesn't inject Node.js polyfills.
        shim_missing_exports: Some(false),

View on GitHub (pinned to 6dee26c6ef)