From 12881e2217a745a3d4a5e56642f0f1dff45f3f41 Mon Sep 17 00:00:00 2001 From: Emmo00 Date: Fri, 23 Jan 2026 18:17:51 +0100 Subject: [PATCH] refactor: improve error handling and resource cleanup in Streamr publishing process --- src/lib/core/streamr/index.ts | 7 ++++++- src/lib/core/streamr/ui.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/core/streamr/index.ts b/src/lib/core/streamr/index.ts index 06bb2cf..8c5ee35 100644 --- a/src/lib/core/streamr/index.ts +++ b/src/lib/core/streamr/index.ts @@ -66,9 +66,14 @@ export default class implements Hooks { await new Promise((resolve) => setTimeout(resolve, 2000)); } catch (error) { console.error(`[streamr] Error publishing to Streamr:`, error); + throw error; } finally { // destroy the client to free resources - await streamrClient.destroy(); + try { + await streamrClient.destroy(); + } catch (destroyError) { + console.error(`[streamr] Error destroying client:`, destroyError); + } } } } diff --git a/src/lib/core/streamr/ui.ts b/src/lib/core/streamr/ui.ts index be89677..b481ca5 100644 --- a/src/lib/core/streamr/ui.ts +++ b/src/lib/core/streamr/ui.ts @@ -151,8 +151,13 @@ export default class implements UIHooks { console.log(`[streamr-ui] Published ${pendingTransactions.length} transactions to stream ${streamId}`); } catch (error) { console.error(`[streamr-ui] Error publishing to Streamr:`, error); + throw error; } finally { - await streamrClient.destroy(); + try { + await streamrClient.destroy(); + } catch (destroyError) { + console.error(`[streamr-ui] Error destroying client:`, destroyError); + } } } }