From ae67f5d47eb6cc3ab4423e08ea07076ef52b6f53 Mon Sep 17 00:00:00 2001 From: Aleksandra Martyniuk Date: Tue, 1 Aug 2023 15:46:35 +0200 Subject: [PATCH] api: ignore future in task_manager_json::wait_task Before returning task status, wait_task waits for it to finish with done() method and calls get() on a resulting future. If requested task fails, an exception will be thrown and user will get internal server error instead of failed task status. Result of done() method is ignored. Fixes: #14914. Closes #14915 --- api/task_manager.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/task_manager.cc b/api/task_manager.cc index f5ecd24ccd..2fcf7a7e86 100644 --- a/api/task_manager.cc +++ b/api/task_manager.cc @@ -192,7 +192,9 @@ void set_task_manager(http_context& ctx, routes& r, db::config& cfg) { task = co_await tasks::task_manager::invoke_on_task(ctx.tm, id, std::function([] (tasks::task_manager::task_ptr task) { return task->done().then_wrapped([task] (auto f) { task->unregister_task(); - f.get(); + // done() is called only because we want the task to be complete before getting its status. + // The future should be ignored here as the result does not matter. + f.ignore_ready_future(); return make_foreign(task); }); }));