fix onExecutionFailedCallBackInfo bug in taskgroup
fix onExecutionFailedCallBackInfo bug in taskgroup

Signed-off-by: huangfeijie <huangfeijie@huawei.com>
This commit is contained in:
huangfeijie 2024-11-12 17:37:54 +08:00
parent c7218eb8d9
commit 3d7203c95c

View File

@ -559,7 +559,10 @@ void TaskPool::UpdateGroupInfoByResult(napi_env env, Task* task, napi_value res,
napi_value res = nullptr;
napi_get_element(env, resArr, groupInfo->GetFailedIndex(), &res);
napi_reject_deferred(env, groupInfo->deferred, res);
if (task->onExecutionFailedCallBackInfo_ != nullptr) {
auto iter = taskGroup->taskIds_.begin();
std::advance(iter, groupInfo->GetFailedIndex());
auto task = iter != taskGroup->taskIds_.end() ? TaskManager::GetInstance().GetTask(*iter) : nullptr;
if (task != nullptr && task->onExecutionFailedCallBackInfo_ != nullptr) {
task->onExecutionFailedCallBackInfo_->taskError_ = res;
task->ExecuteListenerCallback(task->onExecutionFailedCallBackInfo_);
}