cloudflare / cloudflare/workers-rs
No access to Env in #[wasm_bindgen] RPC functions
- Dominant language
- Rust
- Stars
- 3.7k
- Forks
- 429
- Avg merge
- 20h 28m
- Merged PRs (30d)
- 7
Description
It seems it is currently not possible to access the Env inside functions exposed via #[wasm_bindgen] and used in Workers RPC. This limitation makes it difficult to use RPC endpoints for any functionality that depends on environment bindings (e.g., Hyperdrive, secrets, KV, etc.).
```
#[wasm_bindgen]
pub async fn add(a: u32, b: u32) -> u32 {
// Access Env somehow....
a + b
}
```
There should be a way to access the Env, similar to how it is provided to the fetch handler.
Contributor guide
Research direction
Start by tracing how #[wasm_bindgen] RPC functions are exposed and how the fetch handler receives Env. Compare the two entry points to determine the intended way to provide Env to RPC functions. Done means RPC endpoints can access bindings such as Hyperdrive, secrets, and KV, with behavior covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- api, backend, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100