From 6be026e0c1293f9d4936287469b4628901f80437 Mon Sep 17 00:00:00 2001 From: Matthias Boehm Date: Wed, 21 Jan 2026 13:41:46 +0100 Subject: [PATCH] Issue #130: Make handlerWrapper compatible with Node.js --- .../aws/custom-resources/resources/utils.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/plugins/aws/custom-resources/resources/utils.js b/lib/plugins/aws/custom-resources/resources/utils.js index 29cca49a94..f4fad8f1ec 100644 --- a/lib/plugins/aws/custom-resources/resources/utils.js +++ b/lib/plugins/aws/custom-resources/resources/utils.js @@ -74,15 +74,18 @@ function getEnvironment(context) { } function handlerWrapper(handler, PhysicalResourceId) { - return async (event, context, callback) => { + return async (event, context) => { // extend the `event` object to include the PhysicalResourceId event = Object.assign({}, event, { PhysicalResourceId }); - return Promise.resolve(handler(event, context, callback)) - .then( - (result) => response(event, context, 'SUCCESS', result), - (error) => response(event, context, 'FAILED', {}, error) - ) - .then((result) => callback(null, result), callback); + + try { + const result = await handler(event, context); + await response(event, context, 'SUCCESS', result); + return result; + } catch (error) { + await response(event, context, 'FAILED', {}, error); + throw error; + } }; }