Skip to content

feat(debug-files): upload Linux debug files and their sources - #8

Merged
Julien-R44 merged 6 commits into
mainfrom
feat/debug-files
Nov 11, 2026
Merged

Julien-R44 merged 6 commits into
mainfrom
feat/debug-files

Conversation

@Julien-R44

Copy link
Copy Markdown
Member

Adds monocle debug-files upload and monocle debug-files check, so Rust users resolve native stack traces without cloning the private Monocle repository.

cargo build --release --locked          # with debug = 1
monocle debug-files upload target/release/api --include-sources
strip target/release/api                # deploy this one

How it works

  • native/ compiles symbolic-debuginfo 13.9, the version the symbolicator uses, to wasm32-unknown-unknown. It reads the GNU build ID and DWARF file list, then writes the source bundle. It is a port of monocle-native-sources: same path mapping, limits, and output. On the symbolicator's own binary, it produces a bundle byte-identical to the Rust tool's.
  • JavaScript reads the source files from disk (only regular files beneath --root, after resolving symlinks) and uploads through the existing /native-symbols/uploads API. No server change.
  • The module is 610 KiB and loads only for debug-files. It ships in wasm/, resolved through the package's own ./monocle_native.wasm export.
  • pnpm build now also runs build:native, which needs Rust (pinned in native/rust-toolchain.toml) and clang. Checks build it before the tests.

Verification

  • New tests compile a C program with DWARF, upload it to a mock API, and check the build ID against readelf, the debug bytes, and the bundle manifest and contents with unzip. They also cover stripped binaries, a wrong --prefix, and a rejected token.
  • End to end against a local Monocle stack, with the packed tarball through npx: a crates.io monocle-sh-sdk app, uploaded, stripped, run. The issue shows main.rs in orders_api::checkout at line 8 with its excerpt. The Docker case (build in /app, upload with --prefix /app from another checkout) resolves the same way.

Julien-R44 and others added 6 commits November 11, 2026 14:37
Add monocle debug-files upload and check. They read ELF/DWARF with symbolic,
the library of the Monocle symbolicator, compiled to WebAssembly from native/,
so source bundles match the ones the server already validates.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1cae2-d5fe-73c2-9af0-f37f8075cdb1
Same switch as monocle-sh/monocle: CI_RUNNER=devbox-mac moves both workflows
to the devbox runners and skips the GitHub pnpm cache, slow outside GitHub.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1cae2-d5fe-73c2-9af0-f37f8075cdb1
Path::is_absolute is always false on wasm32-unknown-unknown, so the module
treated /app as relative and never joined relative DWARF paths to the prefix.
Builds remapped with --remap-path-prefix=/app=. uploaded no sources. Use
has_root, and test the shipped module on a C build with relative paths.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1bb09-bcea-71b2-8dcf-2a8efd5976f1
Co-authored-by: Amp <amp@ampcode.com>
upload read, validated and bundled each file just before sending it, so an
invalid second file failed after the first one was stored. Prepare all files
and source bundles first. Reject build IDs outside the API's 4 to 64 bytes
before any request, name the file in read, ELF and DWARF errors instead of an
unexpected error, and warn when --root or --prefix is passed without
--include-sources.
new Uint8Array(body) only satisfied BodyInit, which rejects
Buffer<ArrayBufferLike>. Type the bytes as NonSharedBuffer instead. Uploading
a 198 MiB debug file peaks at 1.3 GB instead of 1.7 GB.
@Julien-R44
Julien-R44 merged commit 22ed938 into main Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant