From b7774a70662580887a5d7b4ee7ac69ce05d1b55b Mon Sep 17 00:00:00 2001 From: bombjackit <94737161+bombjackit@users.noreply.github.com> Date: Wed, 27 Nov 2024 10:51:55 +0100 Subject: [PATCH 1/2] Update index.ts In _getAllTemplates change try catch with .catch on first call to template.getTemplate, because template.getTemplate is a promise, with externally try catch the error is not catched. If you use this node in node-red (for example using node-red-contrib-cip-st-ethernet-ip), node-red crash with Uncaught Exception --- src/tag-list/index.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/tag-list/index.ts b/src/tag-list/index.ts index c25140d..4771897 100644 --- a/src/tag-list/index.ts +++ b/src/tag-list/index.ts @@ -281,14 +281,10 @@ class TagList { _getAllTemplates (PLC: Controller): Promise { return new Promise (async (resolve, reject) => { for (const tag of this.tags) { - if (tag.type.structure && !this.templates[tag.type.code]) { - - try { - const template = new Template(); - await template.getTemplate(PLC, tag.type.code); - this.templates[tag.type.code] = template; - } catch (e) { /* ignore template fetching errors */ } - + if (tag.type.structure && !this.templates[tag.type.code]) { + const template = new structure_1.Template(); + await template.getTemplate(PLC, tag.type.code).catch((e) => { /* ignore template fetching errors */ }); + this.templates[tag.type.code] = template; } } @@ -316,4 +312,4 @@ class TagList { } export default TagList; -export {tagListTag, tagListTemplates, tagListTagType} \ No newline at end of file +export {tagListTag, tagListTemplates, tagListTagType} From 1a037de6db94be35c013556998fade8e3b1b530b Mon Sep 17 00:00:00 2001 From: bombjackit <94737161+bombjackit@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:13:15 +0100 Subject: [PATCH 2/2] Update index.ts Small change to commit --- src/tag-list/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tag-list/index.ts b/src/tag-list/index.ts index 4771897..8a54141 100644 --- a/src/tag-list/index.ts +++ b/src/tag-list/index.ts @@ -282,9 +282,9 @@ class TagList { return new Promise (async (resolve, reject) => { for (const tag of this.tags) { if (tag.type.structure && !this.templates[tag.type.code]) { - const template = new structure_1.Template(); - await template.getTemplate(PLC, tag.type.code).catch((e) => { /* ignore template fetching errors */ }); - this.templates[tag.type.code] = template; + const template = new Template(); + await template.getTemplate(PLC, tag.type.code).catch((e) => { /* ignore template fetching errors */ }); + this.templates[tag.type.code] = template; } }