From 72e70e787bd78bbd2de34295616eeaa1a4398436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ARS=20=E3=82=AF=E3=82=99=E3=82=A8=E3=83=B3=20=E3=82=A6?= =?UTF-8?q?=E3=82=99=E3=82=A1=E3=83=B3=20=E3=83=98=E3=82=99?= Date: Fri, 12 Dec 2025 14:30:21 +0900 Subject: [PATCH] Fix: Make handlerWrapper compatible with Node.js 24 --- .../aws/custom-resources/resources/utils.js | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lib/plugins/aws/custom-resources/resources/utils.js b/lib/plugins/aws/custom-resources/resources/utils.js index 29cca49a94..332f1dcf2d 100644 --- a/lib/plugins/aws/custom-resources/resources/utils.js +++ b/lib/plugins/aws/custom-resources/resources/utils.js @@ -73,16 +73,30 @@ function getEnvironment(context) { }; } +// function handlerWrapper(handler, PhysicalResourceId) { +// return async (event, context, callback) => { +// // 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); +// }; +// } function handlerWrapper(handler, PhysicalResourceId) { - return async (event, context, callback) => { - // extend the `event` object to include the PhysicalResourceId + return async (event, context) => { // Removed callback parameter 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; + } }; }