Add support for non async hooks

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-11-10 15:16:30 +01:00
parent 678a158303
commit d0c09089a8
2 changed files with 3 additions and 3 deletions
@@ -39,8 +39,8 @@ class BackendLifecycleImpl {
this.logger.info(`Running ${this.#shutdownTasks.length} shutdown tasks...`);
await Promise.all(
this.#shutdownTasks.map(hook =>
hook
.fn()
Promise.resolve()
.then(() => hook.fn())
.catch(e => {
this.logger.error(
`Shutdown hook registered by plugin '${hook.pluginId}' failed with: ${e}`,
@@ -20,7 +20,7 @@ import { createServiceRef } from '../system/types';
* @public
**/
export type BackendLifecycleShutdownHook = {
fn: () => Promise<void>;
fn: () => void | Promise<void>;
};
/**