diff --git a/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp b/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp index e519adb409..7c48d914bf 100644 --- a/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp +++ b/rclcpp/include/rclcpp/experimental/intra_process_manager.hpp @@ -304,9 +304,23 @@ class IntraProcessManager auto service_it = services_.find(service_id); if (service_it == services_.end()) { - throw std::runtime_error( - "There are no services to receive the intra-process request. " - "Do Inter process."); + auto cli = get_client_intra_process(intra_process_client_id); + auto warning_msg = + "Intra-process service gone out of scope. " + "Do inter-process requests.\n" + "Client topic name: " + std::string(cli->get_service_name()); + RCLCPP_WARN(rclcpp::get_logger("rclcpp"), warning_msg.c_str()); + + // Remove all entries of the out-of-scope service + // from the client/service pairs. + for (auto it = clients_to_services_.cbegin(); it != clients_to_services_.cend(); ) { + if (it->second == service_id) { + it = clients_to_services_.erase(it); + } else { + it++; + } + } + return; } auto service_intra_process_base = service_it->second.lock(); if (service_intra_process_base) {