RUST_BACKTRACE=1 prints a useless Rust stack backtrace on ordinary `deno test` failures
Summary
With RUST_BACKTRACE=1 set in the environment, any failing deno test run prints a Rust stack backtrace, even when the failure is a plain JavaScript assertion/throw and there is no Rust panic involved.
After the normal test report, Deno emits:
error: Test failed
Stack backtrace:
0: llhttp_get_error_reason
1: aws_lc_0_40_0_jent_entropy_switch_notime_impl
2: uv_mutex_unlock
...
10: BaseThreadInitThunk
11: RtlUserThreadStart
These frames are the CLI's top-level Rust main-thread frames and are unrelated to the failing test. On release builds the symbols are mangled/meaningless (see above), so the backtrace has zero diagnostic value and is pure noise in CI logs.
Reproduction
fail.test.ts:
Deno.test('fails', () => {
throw new Error('boom')
})
RUST_BACKTRACE=1 deno test fail.test.ts
Expected
A JavaScript test failure should print the JS error and exit non-zero — no Rust backtrace. RUST_BACKTRACE should only affect output when a Rust panic actually occurs.
Actual
error: Test failed is followed by the Rust Stack backtrace: shown above.
Version
deno 2.9.6+336da42 (canary, release, x86_64-pc-windows-msvc)
v8 15.0.245.2-rusty
typescript 6.0.3
OS: Windows 11 (x86_64)
Notes
RUST_BACKTRACE=1is commonly set globally by users and CI images to debug panics; it should not turn ordinary test failures into backtrace dumps.- Likely cause: the generic
error: Test failedexit path (the CLI's top-level error/exit) is routed through the sameanyhow/ExitCodemachinery whoseDisplay/termination honorsRUST_BACKTRACE, instead of only thepanichook doing so. - Suggestion: only emit a Rust backtrace from the panic hook; for regular CLI errors (
Test failedand friends), suppress theStack backtrace:section regardless ofRUST_BACKTRACE.
Source: denoland/deno