From a74231ab0dca200ec1d6b8ba839f40b9079680ce Mon Sep 17 00:00:00 2001 From: Dennis Dawson Date: Tue, 20 May 2025 16:13:12 -0700 Subject: [PATCH] improve client disconnect --- .../modular-tutorials/account-support.js | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/_code-samples/modular-tutorials/account-support.js b/_code-samples/modular-tutorials/account-support.js index 8e237c04de..ba408faae6 100644 --- a/_code-samples/modular-tutorials/account-support.js +++ b/_code-samples/modular-tutorials/account-support.js @@ -32,8 +32,9 @@ async function getAccount() { } finally { // Disconnect from the client - await client.disconnect(); - } + if (client && client.isConnected()) { + await client.disconnect(); + } } } // End of getAccount() async function getNewAccount1() { @@ -78,8 +79,9 @@ async function getAccountFromSeed(my_seed) { } finally { // Disconnect from the client - await client.disconnect(); - } + if (client && client.isConnected()) { + await client.disconnect(); + } } } // End of getAccountFromSeed() // ***************************************************** @@ -169,8 +171,9 @@ async function getXrpBalance() { } finally { // Disconnect from the client - await client.disconnect(); - } + if (client && client.isConnected()) { + await client.disconnect(); + } } } // End of getXrpBalance() // ******************************************************* @@ -202,7 +205,8 @@ async function getTokenBalance() { } finally { // Disconnect from the client - await client.disconnect(); - } + if (client && client.isConnected()) { + await client.disconnect(); + } } } // End of getTokenBalance()