Skip to content

Commit

Permalink
Merge pull request #4272 from wasmerio/issue-4269-fix-virtual-wasmer-…
Browse files Browse the repository at this point in the history
…run-command

fix: Fix async runtime mismatch in virtual "wasmer run" command
  • Loading branch information
syrusakbary authored Oct 26, 2023
2 parents 6d98d63 + 4689b2f commit 28bb3cb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/wasix/src/os/command/builtins/cmd_wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,19 @@ impl CmdWasmer {
}

pub async fn get_package(&self, name: &str) -> Result<BinaryPackage, anyhow::Error> {
// Need to make sure this task runs on the main runtime.
let (tx, rx) = tokio::sync::oneshot::channel();
let specifier = name.parse()?;
BinaryPackage::from_registry(&specifier, &*self.runtime).await
let rt = self.runtime.clone();
self.runtime.task_manager().task_shared(Box::new(|| {
Box::pin(async move {
let res = BinaryPackage::from_registry(&specifier, rt.as_ref()).await;
tx.send(res)
.expect("could not send response to output channel");
})
}))?;
rx.await
.map_err(|_| anyhow::anyhow!("package retrieval response channel died"))?
}
}

Expand Down

0 comments on commit 28bb3cb

Please sign in to comment.