From b22383dffc98fc0805b6da6eb448f34f756bd3a1 Mon Sep 17 00:00:00 2001 From: parag-pv Date: Mon, 5 Aug 2024 10:41:30 -0400 Subject: [PATCH 1/2] Initial commit. Removing listener from promise list --- languages/javascript/src/shared/Events/index.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/languages/javascript/src/shared/Events/index.mjs b/languages/javascript/src/shared/Events/index.mjs index 18c2092a..f4aa70f6 100644 --- a/languages/javascript/src/shared/Events/index.mjs +++ b/languages/javascript/src/shared/Events/index.mjs @@ -177,6 +177,9 @@ const doListen = function(module, event, callback, context, once, internal=false resolve(listenerId) } else { + // Remove the listerner from Promise list on failure to register + const key = module + '.' + event + (hasContext ? `.${contextKey}` : '') + delete listeners.external[key][listenerId] reject(error) } }) @@ -184,7 +187,6 @@ const doListen = function(module, event, callback, context, once, internal=false else { resolve(listenerId) } - return p } } From 8da9b08a86c836190c875204e2ca2799757ab090 Mon Sep 17 00:00:00 2001 From: parag-pv Date: Mon, 5 Aug 2024 10:46:43 -0400 Subject: [PATCH 2/2] Using the existing remove function instead. Updated comment --- languages/javascript/src/shared/Events/index.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/javascript/src/shared/Events/index.mjs b/languages/javascript/src/shared/Events/index.mjs index f4aa70f6..bc458934 100644 --- a/languages/javascript/src/shared/Events/index.mjs +++ b/languages/javascript/src/shared/Events/index.mjs @@ -177,9 +177,9 @@ const doListen = function(module, event, callback, context, once, internal=false resolve(listenerId) } else { - // Remove the listerner from Promise list on failure to register - const key = module + '.' + event + (hasContext ? `.${contextKey}` : '') - delete listeners.external[key][listenerId] + // Remove the listener from external list on failure to subscribe + // TODO: Instead of removing, the failed subscription shouldn't be put into the external list + listeners.remove(listenerId) reject(error) } })