Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Enable DurableObject Storage's transaction API #486

Closed
1 task done
TannerRogalsky opened this issue Mar 20, 2024 · 0 comments
Closed
1 task done

[Feature] Enable DurableObject Storage's transaction API #486

TannerRogalsky opened this issue Mar 20, 2024 · 0 comments

Comments

@TannerRogalsky
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Description

The function that creates a transaction for a DurableObject's Storage is currently commented out. See here:

// TODO(nilslice): follow up with runtime team on transaction API in general
// This function doesn't work on stable yet because the wasm_bindgen `Closure` type is still nightly-gated
// #[allow(dead_code)]
// async fn transaction<F>(&mut self, closure: fn(Transaction) -> F) -> Result<()>
// where
// F: Future<Output = Result<()>> + 'static,
// {
// let mut clos = |t: Transaction| {
// future_to_promise(async move {
// closure(t)
// .await
// .map_err(JsValue::from)
// .map(|_| JsValue::NULL)
// })
// };
// JsFuture::from(self.inner.transaction_internal(&mut clos)?)
// .await
// .map_err(Error::from)
// .map(|_| ())
// }

The comment about nightly features is no longer relevant and I have a local changeset that enables this functionality with the existing dependency versions.

The documentation on this API indicates that it shouldn't generally be necessary to invoke this but there are still some cases where it is useful: https://developers.cloudflare.com/durable-objects/api/transactional-storage-api/#supported-options-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants