The application is built on top of actix-web 3.0 accessing MongoDB via 1.1.1 driver on tokio runtime.
when building the application with cargo, the building process hangs on one line of code.
#[post("/search_username")]
pub(crate) async fn query_user(
mongo_conn: Data<Client>,
form: web::Form<Username>
) -> HttpResponse {
let username = &form.username;
let collection = mongo_conn.database("ngiam-db").collection("userEntity");
let filter = doc! {"username":username};
let fo = FindOptions::builder()
.projection(doc! {"username":1, "displayName":1, "groupChain":1,
"_id":0}) .build();
let cursor = collection.find(filter, fo).await; ######### this line
聽
unimplemented!()
}
strace cargo build reports

the hanging rustc process eventually exhausts all memory.
This issue currently can be avoided by switching MongoDB driver to async-std runtime.
MongoDB driver maintainer suggests it might be one of proc macro in actix-web causing the issue.
MCVE is available at here
Discussion with the MongoDB driver maintainer is available here
Nah it most likely have nothing to do with proc macros. You can remove the macros and try it again to see if it solves the issue for you.
Similar issue has been reported and it's solved by pinning rustc to a lower version for example 1.44.0 stable.
The course of the memory leak is yet unknown to me so I wouldn't comment on the issue is cause by which or what.
I have also had rust 1.46 hang while compiling. I had to downgrade to 1.45.2.
Might be related to rust issue https://github.com/rust-lang/rust/issues/75992
Same problem on my machine:
P.S. Problem solved with update to rust 1.48
New readers, please try again with rustc 1.48 and/or latest nightly and report back.
Once we have a few reports of the problem being solved we can close this.
1.48 fixed this issue for me.
Most helpful comment
1.48 fixed this issue for me.