diff --git a/crates/cli/src/commands/mod.rs b/crates/cli/src/commands/mod.rs index da78bdd6..6b81cd3c 100644 --- a/crates/cli/src/commands/mod.rs +++ b/crates/cli/src/commands/mod.rs @@ -69,16 +69,18 @@ pub struct Options { impl Options { pub async fn run(self, figment: &Figment) -> anyhow::Result<()> { use Subcommand as S; + // We Box the futures for each subcommand so that we avoid this function being + // big on the stack all the time match self.subcommand { - Some(S::Config(c)) => c.run(figment).await, - Some(S::Database(c)) => c.run(figment).await, - Some(S::Server(c)) => c.run(figment).await, - Some(S::Worker(c)) => c.run(figment).await, - Some(S::Manage(c)) => c.run(figment).await, - Some(S::Templates(c)) => c.run(figment).await, - Some(S::Debug(c)) => c.run(figment).await, - Some(S::Doctor(c)) => c.run(figment).await, - None => self::server::Options::default().run(figment).await, + Some(S::Config(c)) => Box::pin(c.run(figment)).await, + Some(S::Database(c)) => Box::pin(c.run(figment)).await, + Some(S::Server(c)) => Box::pin(c.run(figment)).await, + Some(S::Worker(c)) => Box::pin(c.run(figment)).await, + Some(S::Manage(c)) => Box::pin(c.run(figment)).await, + Some(S::Templates(c)) => Box::pin(c.run(figment)).await, + Some(S::Debug(c)) => Box::pin(c.run(figment)).await, + Some(S::Doctor(c)) => Box::pin(c.run(figment)).await, + None => Box::pin(self::server::Options::default().run(figment)).await, } }