SilverMira opened issue #14291:
Hello, sorry for commenting on this old issue, but with the new
component-model-asyncAPIs, I couldn't find a way to drop a guest's resource, I'm within awasmtime::component::AccessorTaskwith a guest exportedResourceAny, and I couldn't useaccessor.with(|store| resource.resource_drop_async(store))due to trying to return a future that capturesstore.For now, I'm writing as
accessor.with(|store| futures::block_on(resource.resource_drop_async(store))), but no idea whether this is the intended way, or will it cause deadlocks because it will block the store's event loop_Originally posted by @SilverMira in #9946_
As confirmed by @alexcrichton in the above issue, Wasmtime doesn't yet have an intended way to drop a guest's
ResourceAnywithinStore::run_concurrentWe probably need something like a
async fn resource_drop_concurrent(self, accessor: impl AsAccessor) -> wasmtime::Result<()>onResourceAny
alexcrichton added the wasm-proposal:component-model-async label to Issue #14291.
alexcrichton added the wasmtime:api label to Issue #14291.
Byte-Naut commented on issue #14291:
Thanks @SilverMira for tracking this down and @alexcrichton for pointing at
the shape of the missing API.I've opened #<PR-NUMBER> which adds
ResourceAny::resource_drop_concurrent(self, accessor: impl AsAccessor).
It queues the drop on the store's worker fiber, so theAccessor::with
borrow ends before the await and nothing blocks the event loop. The
block_onworkaround from the original report should no longer be needed.I also added a test that reproduces the
AccessorTaskcase from this issue,
and updated theresource_dropdocs to explain when to use each of the
three variants, which touches on some of the documentation feedback from
#9946.Feedback on the API or the cancellation semantics is very welcome.
Byte-Naut edited a comment on issue #14291:
Thanks @SilverMira for tracking this down and @alexcrichton for pointing at the shape of the missing API.
I've opened #14362 which adds
ResourceAny::resource_drop_concurrent(self, accessor: impl AsAccessor). It queues the drop on the store's worker fiber, so theAccessor::withborrow ends before the await and nothing blocks the event loop. Theblock_onworkaround from the original report should no longer be needed.I also added a test that reproduces the
AccessorTaskcase from this issue, and updated theresource_dropdocs to explain when to use each of the three variants, which touches on some of the documentation feedback from #9946.Feedback on the API or the cancellation semantics is very welcome.
Last updated: Sep 20 2026 at 18:08 UTC