Problem
The flagd crate cannot compile to wasm32-unknown-unknown for use in Cloudflare Workers or other WASM environments. The crate's provider stack — gRPC, HTTP, file watching, and caching — all depend on tokio with rt, rt-multi-thread, and net features, which require OS-level I/O primitives not available in WASM:
| Component |
Dependency |
Blocker |
| RPC / in-process resolver |
tokio, tonic |
Requires OS I/O, not WASM-compatible |
| REST resolver |
tokio, reqwest |
Requires OS networking |
| File sync / watching |
tokio, notify |
Requires OS file system |
| Cache |
tokio |
Requires async runtime |
Note: open-feature/rust-sdk#127 (pending) fixes the open-feature crate's own WASM incompatibility by narrowing its tokio dependency from features = ["full"] to just features = ["sync"], which is WASM-compatible. The blockers above are independent of that and exist in the flagd crate itself.
The flagd evaluation logic (JSONLogic rules, fractional rollouts, semver, string operators) is fully synchronous and has no inherent WASM incompatibility — the blocker is entirely the provider/networking infrastructure.
Proposed Solution
Add an opt-in wasm feature to the flagd crate that:
- Gates all async/networking dependencies (
tokio rt/net, tonic, reqwest, notify) behind a tokio feature flag
- Introduces a lightweight
WasmEvaluationContext as a WASM-compatible replacement for open_feature::EvaluationContext
- Adds a
SimpleFlagStore for synchronous flag evaluation against static/bundled configuration, with no async runtime or networking required
Default behavior is unchanged — existing consumers continue to work without modification.
Required Changes (crates/flagd/)
- Add
wasm feature to Cargo.toml; gate all async/networking deps behind a tokio feature flag
- Gate
FlagdProvider, FlagdOptions, ResolverType, and all tokio-dependent code behind #[cfg(feature = "tokio")]
- Add
WasmEvaluationContext — a lightweight evaluation context usable without the full OpenFeature SDK
- Add
SimpleFlagStore — synchronous flag loading and evaluation for static/bundled configurations
- Update targeting resolution to use
WasmEvaluationContext when building with wasm feature
- Add compatibility tests confirming correct evaluation under
wasm feature (targeting rules, fractional, semver, string operators)
Reference
A working prototype lives at DevCycleHQ-Sandbox/rust-sdk-contrib on branch feat/wasm-support, validated end-to-end in a Cloudflare Worker exposing the OFREP API.
Problem
The
flagdcrate cannot compile towasm32-unknown-unknownfor use in Cloudflare Workers or other WASM environments. The crate's provider stack — gRPC, HTTP, file watching, and caching — all depend ontokiowithrt,rt-multi-thread, andnetfeatures, which require OS-level I/O primitives not available in WASM:tokio,tonictokio,reqwesttokio,notifytokioNote: open-feature/rust-sdk#127 (pending) fixes the
open-featurecrate's own WASM incompatibility by narrowing its tokio dependency fromfeatures = ["full"]to justfeatures = ["sync"], which is WASM-compatible. The blockers above are independent of that and exist in theflagdcrate itself.The flagd evaluation logic (JSONLogic rules, fractional rollouts, semver, string operators) is fully synchronous and has no inherent WASM incompatibility — the blocker is entirely the provider/networking infrastructure.
Proposed Solution
Add an opt-in
wasmfeature to theflagdcrate that:tokiort/net,tonic,reqwest,notify) behind atokiofeature flagWasmEvaluationContextas a WASM-compatible replacement foropen_feature::EvaluationContextSimpleFlagStorefor synchronous flag evaluation against static/bundled configuration, with no async runtime or networking requiredDefault behavior is unchanged — existing consumers continue to work without modification.
Required Changes (
crates/flagd/)wasmfeature toCargo.toml; gate all async/networking deps behind atokiofeature flagFlagdProvider,FlagdOptions,ResolverType, and all tokio-dependent code behind#[cfg(feature = "tokio")]WasmEvaluationContext— a lightweight evaluation context usable without the full OpenFeature SDKSimpleFlagStore— synchronous flag loading and evaluation for static/bundled configurationsWasmEvaluationContextwhen building withwasmfeaturewasmfeature (targeting rules, fractional, semver, string operators)Reference
A working prototype lives at
DevCycleHQ-Sandbox/rust-sdk-contribon branchfeat/wasm-support, validated end-to-end in a Cloudflare Worker exposing the OFREP API.