From 5d61095e7ed01e200be01772006a082cc7fe9186 Mon Sep 17 00:00:00 2001 From: hidetak Date: Mon, 4 Mar 2024 17:19:59 +0900 Subject: [PATCH 1/2] fixed to catch errors when servient termination fails --- node-red-node-wot/src/servients/servient-manager.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node-red-node-wot/src/servients/servient-manager.ts b/node-red-node-wot/src/servients/servient-manager.ts index 4bc6dde..3c82061 100644 --- a/node-red-node-wot/src/servients/servient-manager.ts +++ b/node-red-node-wot/src/servients/servient-manager.ts @@ -37,7 +37,11 @@ export default class ServientManager { console.warn("[warn] timeout happend while servient ending. id: " + id) resolve() }, 10000) // If it does not end after 10 seconds, it is considered to be finished. - await servientWrapper.endServient() + try { + await servientWrapper.endServient() + } catch (err) { + reject(err) + } console.debug("[debug] servient ended. id: " + id) clearTimeout(timeoutId) resolve() From 03546b7c3cb12289ae0dd6372987d9f1bc12d78f Mon Sep 17 00:00:00 2001 From: hidetak Date: Mon, 4 Mar 2024 17:33:21 +0900 Subject: [PATCH 2/2] fixed to catch errors when servient termination fails --- node-red-node-wot/src/servients/servient-manager.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/node-red-node-wot/src/servients/servient-manager.ts b/node-red-node-wot/src/servients/servient-manager.ts index 3c82061..99756ee 100644 --- a/node-red-node-wot/src/servients/servient-manager.ts +++ b/node-red-node-wot/src/servients/servient-manager.ts @@ -39,12 +39,14 @@ export default class ServientManager { }, 10000) // If it does not end after 10 seconds, it is considered to be finished. try { await servientWrapper.endServient() + console.debug("[debug] servient ended. id: " + id) + clearTimeout(timeoutId) + resolve() } catch (err) { + console.debug("[debug] failed to end servient. id: " + id + " error: " + err.toString()) + clearTimeout(timeoutId) reject(err) } - console.debug("[debug] servient ended. id: " + id) - clearTimeout(timeoutId) - resolve() }) }