Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1099

Async drop tasks can panic if runtime goes out of scope before they finish

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.7.0
    • Affects Version/s: None
    • Component/s: None

      Drop implementations that spawn async tasks (e.g. the drop in cursor executes a killCursors command) can panic if the tokio runtime gets dropped before they execute. This isn't a huge concern because usually the runtime is only dropped on application exit, but we should still try to exit more gracefully if possible.

      repro (ensure there are at least two documents):

      Unable to find source-code formatter for language: rust. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      #[tokio::main]
      async fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
          let mut options = ClientOptions::parse("mongodb://localhost:27017").await?;
          let client = Client::with_options(options)?;
      
          let options =FindOptions::builder().batch_size(1).build();
          client
              .database("list_collections")
              .find(doc! {}, options)
              .await?;
          Ok(())
      }
      

            Assignee:
            abraham.egnor@mongodb.com Abraham Egnor
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: