You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/quotesdb/.beans/quotesdb-wizu--triage-worke...

2.1 KiB

title status type priority created_at updated_at
[TRIAGE] workers-rs compatibility with native Rust test binaries (may need separate native feature flag) completed task critical 2026-03-10T23:32:09Z 2026-03-10T23:32:09Z
This is a triage decision ticket. It must be resolved before dependent implementation tickets can proceed. workers-rs compatibility with native Rust test binaries: the workers-rs crate targets the Cloudflare Workers runtime, not native Linux/macOS. Can the API code be compiled as a native binary for `cargo test`? 1. **Conditional compilation** — use `#[cfg(target_env = "worker")]` to switch between workers-rs entry point and a plain Axum server. The native build is used for testing. 2. **Feature flags** — add a `native` feature that enables the Axum server path. `cargo test` uses `--features native`. 3. **Separate test binary** — integration tests spawn a separately compiled native test server binary. **Option 1 variant: `cfg(target_arch = "wasm32")` — no feature flag needed.**

Note: target_env = "worker" is incorrect. The right discriminant is target_arch = "wasm32".

The cfg(target_arch) split is cleaner than a feature flag because it is tied to the actual build target, not an opt-in flag that could be forgotten:

  • [target.'cfg(target_arch = "wasm32")'.dependencies] → workers-rs (pulled in only for WASM)
  • [target.'cfg(not(target_arch = "wasm32"))'.dependencies] → tokio, axum, rusqlite (native only)

In main.rs:

#[cfg(target_arch = "wasm32")]
#[worker::event(fetch)]
pub async fn main(...) { /* workers-rs entry point */ }

#[cfg(not(target_arch = "wasm32"))]
#[tokio::main]
async fn main() { /* native Axum server on :8080 */ }

cargo test (native host) automatically compiles the native path. No special flags. No feature flag pollution. Resolved as part of TRIAGE e8a330 (DB strategy decision).

See implementation ticket 00aff0 for full details.

`chore(quotesdb): resolve triage — workersrs-compatibility-with-native-rust-test-binaries-may-n`