From fd82561875fd45136dca9d71e9c1bcc6e8f9cf8a Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Mon, 12 Feb 2024 09:20:32 +0000 Subject: [PATCH] fix: use `allSettled` instead of `all` such that `fireLifecycleEvent` doesn't throw --- .../client/src/framework/lifecycle.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/how-to/workspace-platform-starter/client/src/framework/lifecycle.ts b/how-to/workspace-platform-starter/client/src/framework/lifecycle.ts index 8ec66ce918..a78bcc28de 100644 --- a/how-to/workspace-platform-starter/client/src/framework/lifecycle.ts +++ b/how-to/workspace-platform-starter/client/src/framework/lifecycle.ts @@ -73,12 +73,18 @@ export async function fireLifecycleEvent( // the loop gets out of sync and items can be missed const subscribers = [...eventHandlers.subscribers]; - await Promise.all( + const subscriberResults = await Promise.allSettled( subscribers.map(async (idHandler) => { logger.info(`Notifying subscriber ${idHandler.id} of event ${lifecycleEvent}`); await idHandler.handler(platform, payload); + return idHandler.id; }) ); + for (const result of subscriberResults) { + if (result.status === "rejected") { + logger.error(`Error notifying subscriber of lifecycle event ${lifecycleEvent}`, result.reason); + } + } } }