From 20f47f4db796846392fc6d533b4831b17f68285c Mon Sep 17 00:00:00 2001 From: Scott Newcomer Date: Thu, 28 Oct 2021 15:51:26 -0500 Subject: [PATCH] Ensure no unhandledrejection if canceled (#8) --- addon/decorators/stateful-function.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addon/decorators/stateful-function.js b/addon/decorators/stateful-function.js index 1751c5b..f31c64c 100644 --- a/addon/decorators/stateful-function.js +++ b/addon/decorators/stateful-function.js @@ -63,6 +63,13 @@ export function statefulFunction(target, _property, descriptor) { handler.isRunning = true; + sp.catch((e) => { + // ensure no unhandledrejection if canceled + if (!(e instanceof CanceledPromise)) { + throw e; + } + }); + return sp; };