deno/tools/release/create_symcache.ts
Divy Srivastava e10101347c
perf: remote symbolicate stack traces (#28470)
Fixes #28136 
Closes #28415

Publish symcache to GCS and generate trace URL during panic.

```
============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: windows x86_64
Version: 2.2.5
Args: ["C:\Users\divy\.deno\bin\deno.exe"]

View stack trace at:
https://panic.deno.com/v2.2.5/aarch64-apple-darwin/gszD49_B4utrqB4vrrqBozirqB49prqBwjkwqBw_jBg31Cw5tCg5sDoo3pqB41sDgkkB
```

## Design

<img
src=https://github.com/user-attachments/assets/396d53cd-1fe7-4d88-9ecd-ea7b74a9a1ed
height=500>

Example:
`https://panic.deno.com/v2.2.3/aarch64-apple-darwin/g4couawkboxb4tbg9oHwqbw6a`

Stack walking and symbolicate code is at
https://github.com/denoland/panic/
2025-04-02 08:42:28 +05:30

28 lines
828 B
TypeScript

// Copyright 2018-2025 the Deno authors. MIT license.
// deno-lint-ignore-file no-console
import { createSymcache } from "jsr:@deno/panic@0.1.0";
import path from "node:path";
// Generate symcache for the current Deno executable.
let debugFile = Deno.execPath();
if (Deno.build.os === "windows") {
debugFile = debugFile.replace(/\.exe$/, ".pdb");
} else if (Deno.build.os === "darwin") {
const resolvedPath = Deno.realPathSync(`${debugFile}.dSYM`);
const { name } = path.parse(resolvedPath);
debugFile = path.join(resolvedPath, "Contents/Resources/DWARF", name);
}
const outfile = Deno.args[0];
if (!outfile) {
console.error("Usage: ./target/release/deno -A create_symcache.ts <outfile>");
Deno.exit(1);
}
const symcache = createSymcache(Deno.readFileSync(debugFile));
Deno.writeFileSync(outfile, symcache);