diff --git a/src/throttler_api.cc b/src/throttler_api.cc index 538f40e3b..384b1d0cb 100644 --- a/src/throttler_api.cc +++ b/src/throttler_api.cc @@ -400,7 +400,9 @@ void APIThrottler::ResetClientContext() { void APIThrottler::Close() { std::lock_guard lock(ctx_mutex_); closed_ = true; - ctx_->TryCancel(); + if (ctx_) { + ctx_->TryCancel(); + } } } // namespace profiler