diff --git a/js_concurrent_module/worker/test/test_worker.cpp b/js_concurrent_module/worker/test/test_worker.cpp index 070dde58..1a2a7a41 100644 --- a/js_concurrent_module/worker/test/test_worker.cpp +++ b/js_concurrent_module/worker/test/test_worker.cpp @@ -951,6 +951,11 @@ public: static void ClearWorkerHandle(Worker* worker) { worker->CloseHostHandle(); + if (worker->isLimitedWorker_) { + napi_remove_env_cleanup_hook(worker->hostEnv_, Worker::LimitedWorkerHostEnvCleanCallback, worker); + } else { + napi_remove_env_cleanup_hook(worker->hostEnv_, Worker::WorkerHostEnvCleanCallback, worker); + } } protected: static thread_local NativeEngine *engine_; @@ -3469,7 +3474,6 @@ HWTEST_F(WorkersTest, WorkerTest046, testing::ext::TestSize.Level0) std::string funcName = "GlobalCall"; napi_value cb = nullptr; napi_value callResult = nullptr; - // ------- workerEnv--------- napi_create_function(workerEnv, funcName.c_str(), funcName.size(), Worker::GlobalCall, worker, &cb); UpdateWorkerState(worker, Worker::RunnerState::RUNNING); @@ -3489,6 +3493,7 @@ HWTEST_F(WorkersTest, WorkerTest046, testing::ext::TestSize.Level0) napi_get_and_clear_last_exception(env, &exception); ASSERT_TRUE(exception == nullptr); worker->EraseWorker(); + SetLimitedWorker(worker, false); ClearWorkerHandle(worker); result = Worker_Terminate(env, global); ASSERT_TRUE(result != nullptr);