diff --git a/src/init.cpp b/src/init.cpp index cae52675525..7952495c093 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -298,6 +299,14 @@ void Shutdown(NodeContext& node) StopREST(); StopRPC(); StopHTTPServer(); + for (auto& client : node.chain_clients) { + try { + client->stop(); + } catch (const ipc::Exception& e) { + LogDebug(BCLog::IPC, "Chain client did not disconnect cleanly: %s", e.what()); + client.reset(); + } + } StopMapPort(); // Because these depend on each-other, we make sure that neither can be @@ -370,9 +379,6 @@ void Shutdown(NodeContext& node) } } } - for (const auto& client : node.chain_clients) { - client->stop(); - } // If any -ipcbind clients are still connected, disconnect them now so they // do not block shutdown.