@@ -157,9 +157,8 @@ void FDv2StreamingSynchronizer::State::EnsureStarted(
157157
158158void FDv2StreamingSynchronizer::State::OnConnect (HttpRequest* req) {
159159 std::lock_guard lock (mutex_);
160- if (!base_url_) {
161- return ;
162- }
160+ // base_url_ is guaranteed populated: EnsureStarted publishes it before
161+ // calling async_connect, which is what eventually triggers this hook.
163162 boost::urls::url u = *base_url_;
164163 if (latest_selector_.value ) {
165164 u.params ().set (" basis" , latest_selector_.value ->state );
@@ -252,29 +251,19 @@ void FDv2StreamingSynchronizer::State::OnError(sse::Error const& error) {
252251
253252 LD_LOG (logger_, LogLevel::kError ) << kIdentity << " : " << msg;
254253
255- std::visit (
256- [this , &msg](auto const & e) {
257- using T = std::decay_t <decltype (e)>;
258- if constexpr (std::is_same_v<
259- T, sse::errors::UnrecoverableClientError>) {
260- Notify (FDv2SourceResult{FDv2SourceResult::TerminalError{
261- MakeError (ErrorKind::kErrorResponse ,
262- static_cast <ErrorInfo::StatusCodeType>(e.status ),
263- std::move (msg)),
264- false }});
265- } else if constexpr (std::is_same_v<
266- T, sse::errors::InvalidRedirectLocation> ||
267- std::is_same_v<T,
268- sse::errors::NotRedirectable> ||
269- std::is_same_v<T, sse::errors::ReadTimeout>) {
270- Notify (FDv2SourceResult{FDv2SourceResult::TerminalError{
271- MakeError (ErrorKind::kNetworkError , 0 , std::move (msg)),
272- false }});
273- } else {
274- static_assert (always_false_v<T>, " non-exhaustive visitor" );
275- }
276- },
277- error);
254+ if (auto const * client_error =
255+ std::get_if<sse::errors::UnrecoverableClientError>(&error)) {
256+ Notify (FDv2SourceResult{FDv2SourceResult::TerminalError{
257+ MakeError (
258+ ErrorKind::kErrorResponse ,
259+ static_cast <ErrorInfo::StatusCodeType>(client_error->status ),
260+ std::move (msg)),
261+ false }});
262+ return ;
263+ }
264+
265+ Notify (FDv2SourceResult{FDv2SourceResult::TerminalError{
266+ MakeError (ErrorKind::kNetworkError , 0 , std::move (msg)), false }});
278267}
279268
280269void FDv2StreamingSynchronizer::State::Notify (FDv2SourceResult result) {
@@ -377,6 +366,9 @@ async::Future<FDv2SourceResult> FDv2StreamingSynchronizer::Next(
377366 }
378367 if (idx == 1 ) {
379368 state->ClearPendingPromise ();
369+ if (result_future.IsFinished ()) {
370+ return *result_future.GetResult ();
371+ }
380372 return FDv2SourceResult{FDv2SourceResult::Timeout{}};
381373 }
382374 return *result_future.GetResult ();
0 commit comments