Skip to content

Commit af4ceab

Browse files
authored
Enable backtraces in turbopack integration tests (#89935)
## Enable Rust backtraces in CI tests ### What? Added `RUST_BACKTRACE=1` environment variable to all Turbopack-related test workflows. ### Why? This change enables detailed Rust backtraces when Turbopack encounters errors during CI tests, making it easier to diagnose and fix issues that occur in the Rust components. Notably, some assertions/panics are about detecting race conditions, e.g. ``` thread 'tokio-runtime-worker' (1056161) panicked at turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs:426:13: Concurrent task lock acquisition detected. This is not allowed and indicates a bug. It can lead to deadlocks. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` Rather than painfully attempting to reproduce locally we can just run with the env var all the time and perhaps that will be enough to figure out rare issues
1 parent e9b96b4 commit af4ceab

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

.github/workflows/build_and_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ jobs:
256256
export NEXT_TEST_MODE=dev
257257
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
258258
export __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true
259+
export RUST_BACKTRACE=1
259260
260261
node run-tests.js \
261262
--test-pattern '^(test\/(development|e2e))/.*\.test\.(js|jsx|ts|tsx)$' \
@@ -287,6 +288,7 @@ jobs:
287288
export TURBOPACK_DEV=1
288289
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
289290
export __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true
291+
export RUST_BACKTRACE=1
290292
291293
node run-tests.js \
292294
--timings \
@@ -318,6 +320,7 @@ jobs:
318320
export NEXT_TEST_MODE=start
319321
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
320322
export __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true
323+
export RUST_BACKTRACE=1
321324
322325
node run-tests.js --timings -g ${{ matrix.group }} --type production
323326
stepName: 'test-turbopack-production-react-${{ matrix.react }}-${{ matrix.group }}'
@@ -346,6 +349,7 @@ jobs:
346349
export TURBOPACK_BUILD=1
347350
export NEXT_TEST_REACT_VERSION="${{ matrix.react }}"
348351
export __NEXT_EXPERIMENTAL_STRICT_ROUTE_TYPES=true
352+
export RUST_BACKTRACE=1
349353
350354
node run-tests.js \
351355
--timings \

.github/workflows/turbopack-nextjs-build-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: turbopack-production
1414
test_type: production
1515
run_before_test: |
16-
export IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1
16+
export IS_TURBOPACK_TEST=1 TURBOPACK_BUILD=1 RUST_BACKTRACE=1
1717
# Failing tests take longer (due to timeouts and retries). Since we have
1818
# many failing tests, we need smaller groups and longer timeouts, in case
1919
# a group gets stuck with a cluster of failing tests.

.github/workflows/turbopack-nextjs-dev-integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ jobs:
1313
name: turbopack-development
1414
test_type: development
1515
run_before_test: |
16-
export IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1
16+
export IS_TURBOPACK_TEST=1 TURBOPACK_DEV=1 RUST_BACKTRACE=1
1717
secrets: inherit

turbopack/crates/turbopack-ecmascript-plugins/src/transform/swc_ecma_transform_plugins.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,22 @@ impl CustomTransformer for SwcEcmaTransformPluginsTransformer {
299299
Err(e) => {
300300
use turbopack_core::issue::IssueExt;
301301

302+
// Format the error chain without backtrace.
303+
// Using `{:?}` would include the backtrace when
304+
// RUST_BACKTRACE=1, which is not useful in
305+
// user-facing error messages.
306+
let mut description = e.to_string();
307+
let mut causes = e.chain().skip(1).peekable();
308+
if causes.peek().is_some() {
309+
description.push_str("\n\nCaused by:");
310+
for (i, cause) in causes.enumerate() {
311+
description.push_str(&format!("\n {i}: {cause}"));
312+
}
313+
}
314+
302315
SwcEcmaTransformFailureIssue {
303316
file_path: ctx.file_path.clone(),
304-
description: StyledString::Text(format!("{:?}", e).into()),
317+
description: StyledString::Text(description.into()),
305318
}
306319
.resolved_cell()
307320
.emit();

0 commit comments

Comments
 (0)