cloudflare / workers-rs

Write Cloudflare Workers in 100% Rust via WebAssembly
Apache License 2.0
2.53k stars 269 forks source link

Alarm APIs are incorrectly marked as async #623

Closed DylanRJohnston closed 1 month ago

DylanRJohnston commented 1 month ago

https://github.com/cloudflare/workers-rs/blob/aaf5c672c0830e6637d671b4e70c6251fda0c835/worker-sys/src/types/durable_object/storage.rs#L65-L70

The docs on alarms indicate they're not async https://developers.cloudflare.com/durable-objects/api/alarms/#setalarm.

kflansburg commented 1 month ago

Does this prevent things from working? I suppose this will have to be a breaking change.

DylanRJohnston commented 1 month ago

I don't believe so, although it's not entirely clear what code wasm_bindgen generates in this case. I suspect what happens is the same thing as when you have an async js function without any awaits. It just gets turn into an immediately resolving promise.

When I opened this issue I was encountering some issues with waking up from alarms, but that turned out to be an unrelated problem. So it seems pretty harmless that this API isn't really async.

Although I am curious about what's going on under the hood with the worker runtime that allows this method not to be async on the JS side.