diff --git a/src/core/client_channel/client_channel_filter.cc b/src/core/client_channel/client_channel_filter.cc index f80f20cc88d..70ef58f52ca 100644 --- a/src/core/client_channel/client_channel_filter.cc +++ b/src/core/client_channel/client_channel_filter.cc @@ -2518,16 +2518,17 @@ ClientChannelFilter::LoadBalancedCall::PickSubchannel(bool was_queued) { // updated before we queue it. // We need to unref pickers in the WorkSerializer. std::vector> pickers; - auto cleanup = absl::MakeCleanup([&]() { - if (IsWorkSerializerDispatchEnabled()) return; - chand_->work_serializer_->Run( - [pickers = std::move(pickers)]() mutable { - for (auto& picker : pickers) { - picker.reset(DEBUG_LOCATION, "PickSubchannel"); - } - }, - DEBUG_LOCATION); - }); + auto cleanup = absl::MakeCleanup( + [work_serializer = chand_->work_serializer_, &pickers]() { + if (IsWorkSerializerDispatchEnabled()) return; + work_serializer->Run( + [pickers = std::move(pickers)]() mutable { + for (auto& picker : pickers) { + picker.reset(DEBUG_LOCATION, "PickSubchannel"); + } + }, + DEBUG_LOCATION); + }); absl::AnyInvocable)> set_picker; if (!IsWorkSerializerDispatchEnabled()) {