diff --git a/crates/meilisearch/src/routes/indexes/documents.rs b/crates/meilisearch/src/routes/indexes/documents.rs index 264365704..5f79000bd 100644 --- a/crates/meilisearch/src/routes/indexes/documents.rs +++ b/crates/meilisearch/src/routes/indexes/documents.rs @@ -624,12 +624,19 @@ async fn document_addition( None => None, }; - let documents_count = file.as_ref().map_or(Ok(0), |ntf| { - read_ndjson(ntf.as_file()).map_err(MeilisearchHttpError::DocumentFormat) - })?; - let update_file = file_store::File::from_parts(path, file); - update_file.persist()?; - Ok(Ok(documents_count)) + let documents_count = tokio::task::spawn_blocking(move || { + let documents_count = file.as_ref().map_or(Ok(0), |ntf| { + read_ndjson(ntf.as_file()).map_err(MeilisearchHttpError::DocumentFormat) + })?; + + let update_file = file_store::File::from_parts(path, file); + update_file.persist()?; + + Ok(documents_count) + }) + .await?; + + Ok(documents_count) } PayloadType::Json | PayloadType::Csv { delimiter: _ } => { let temp_file = match tempfile() {