# Troubleshooting


Most setup problems come down to a missing key, a filter in the wrong place, or a build without debug info. Look up what you see below.

When you're not sure where to start, run your app with `FLARE_DEBUG=true`. Flare then prints a line to stderr for every request it sends, with the status code it gets back, and the answer when a request fails.

## Errors

### Nothing arrives in Flare

Run your app with `FLARE_DEBUG=true` first. Most of the time, it's one of these:

**`FLARE_KEY` isn't set for the process that runs your app.** Flare then prints `no API key set, Flare is disabled`. A `.env` file only counts when it's in the folder your app runs in. Flare doesn't look in parent folders. Flare also stops reading a `.env` file at the first line it can't parse, and with `FLARE_DEBUG=true` it tells you when that happens.

**The guard of `flareapp::init` is dropped right away.** This only applies when you start Flare without `#[flareapp::main]`. `let _ = ...` drops the guard on the same line, and Flare stops again. Keep it in a named variable:

```rust
// Flare stops right away.
let _ = flareapp::init(flareapp::config!());

// Flare runs until the end of `main`.
let _flare = flareapp::init(flareapp::config!());
```

**Your program ends with `std::process::exit`.** That skips the code that sends the last data. Call `flareapp::flush` right before it:

```rust
use std::time::Duration;

flareapp::flush(Duration::from_secs(2));
std::process::exit(1);
```

### An error returned from `main` isn't reported

`#[flareapp::main]` recognizes the error by the name of the return type, so the type has to be named `Result`. A type alias with another name isn't reported:

```rust
type AppResult = Result<(), Box<dyn std::error::Error>>;

// The error isn't reported.
#[flareapp::main]
fn main() -> AppResult {
    Ok(())
}

// The error is reported.
#[flareapp::main]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    Ok(())
}
```

### A user shows up on the errors of other requests

The user was set outside the scope of the request, so it went to the app-wide scope instead. That happens when your authentication middleware runs before the Flare middleware, see [middleware order](/docs/rust/data-collection/scopes#middleware-order). It also happens in a task you `tokio::spawn`, because a spawned task doesn't get the scope of the request. Give it a scope of its own, as in [spawned tasks](/docs/rust/data-collection/scopes#spawned-tasks).

### Frames have no files or line numbers

The binary has no debug info. Set `debug = "limited"` in your release profile, or [upload your debug files](/docs/rust/errors/release-builds-and-debug-files#uploading-debug-files).

On Windows, the debug info lives in a `.pdb` file next to the `.exe`. Deploy it together with the `.exe`, or upload it.

## Logs and traces

### Logs or traces don't arrive

Logs need `send_logs` on the layer, and traces need `FLARE_TRACES_SAMPLE_RATE`. Both only work with the private API key of your project.

### SQLx queries are missing from your traces

A filter on the whole subscriber, like `.with(LevelFilter::INFO)` or an `EnvFilter` built from `RUST_LOG=info`, drops the DEBUG events that SQLx writes for its queries. Move the filter to the `fmt` layer, as shown in [where your filters go](/docs/rust/logs/introduction#where-your-filters-go). Or let the queries through with `RUST_LOG=info,sqlx::query=debug`.

A query also has to run inside a trace, such as a request. A query outside of any span, like a migration when your app starts, isn't sent. And the query spans need SQLx 0.9.

### A trace shows up long after its request

Flare sends a trace when its root span, the outermost one, closes. That span only closes when every span below it has closed. A task you `tokio::spawn` from a request, with the request span as its parent, keeps the request span open until the task is done. Give such a task a trace of its own, as described in [spawned tasks](/docs/rust/tracing/instrumenting-your-code#spawned-tasks).

### Every URL shows up as its own route

With axum, turn on the `axum` feature, not just `tower`, and add the middleware with `.layer()` after your routes.

Requests that don't match any route have no route to group on, such as the ones that end up in `.fallback()` in axum or `.default_service()` in Actix Web. Flare then groups them on the path, with ids and numbers replaced by `*`. In axum, a catch-all route like `/{*path}` instead of `.fallback()` puts all of them on one row.

## Debug file uploads

### `the file has no GNU build ID` on Linux

The binary was built without a build ID. Add `-C link-arg=-Wl,--build-id` to your `RUSTFLAGS` or `.cargo/config.toml`. If you set it in `.cargo/config.toml`, check that your pipeline doesn't also set `RUSTFLAGS`, because that replaces the flags from the file.

### `found no debug files that Flare can use`

On Linux, the binary was stripped before its debug info was copied, so there's nothing left to upload. Run `objcopy --only-keep-debug` before `objcopy --strip-debug`, as in [step 3 of the upload guide](/docs/rust/errors/release-builds-and-debug-files#step-3-split-off-the-debug-info-on-linux).

On macOS, the build didn't write a `.dSYM` bundle. Set `CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO=packed` for the build, and check that `target/release` has a `my-app.dSYM` next to your binary.

### `the file has no debug information`

The release profile has no `debug` setting, or it strips the binary during the build. Set `debug = "limited"`, and don't set `strip` in the profile you upload from.

### The upload works, but frames still have no functions

The binary you deployed isn't the one you uploaded. Run `cargo flareapp check` on the deployed binary, and compare its debug ID with the one in the upload output. A binary that's built again after the upload, for example in a separate deploy job, can end up with a different debug ID, and then it needs its own upload.

### The upload hangs or times out behind a firewall

The CLI sends files straight to Flare's file storage over HTTPS, not through the Flare API. Allow outgoing HTTPS from your build machine to that storage as well.

## Read more

- [Configuration](/docs/rust/reference/configuration): every environment variable, including `FLARE_DEBUG`.
- [When the upload fails](/docs/rust/errors/uploading-debug-files-in-ci#when-the-upload-fails): which upload problems fail your build, and which don't.
