diff --git a/src/init.cpp b/src/init.cpp index f949e1fa8fd..b9de7452840 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -298,8 +299,13 @@ void Shutdown(NodeContext& node) StopREST(); StopRPC(); StopHTTPServer(); - for (const auto& client : node.chain_clients) { - client->flush(); + for (auto& client : node.chain_clients) { + try { + client->flush(); + } catch (const ipc::Exception& e) { + LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what()); + client.reset(); + } } StopMapPort(); @@ -374,7 +380,7 @@ void Shutdown(NodeContext& node) } } for (const auto& client : node.chain_clients) { - client->stop(); + if (client) client->stop(); } #ifdef ENABLE_ZMQ