Skip to content

Commit 2d7f527

Browse files
authored
Merge pull request #136 from MatthiasBoehm87/fix/custom-resources-with-nodejs24
Issue #130: Make handlerWrapper compatible with Node.js 24
2 parents 1f39b64 + 6be026e commit 2d7f527

File tree

1 file changed

+10
-7
lines changed
  • lib/plugins/aws/custom-resources/resources

1 file changed

+10
-7
lines changed

lib/plugins/aws/custom-resources/resources/utils.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,18 @@ function getEnvironment(context) {
7474
}
7575

7676
function handlerWrapper(handler, PhysicalResourceId) {
77-
return async (event, context, callback) => {
77+
return async (event, context) => {
7878
// extend the `event` object to include the PhysicalResourceId
7979
event = Object.assign({}, event, { PhysicalResourceId });
80-
return Promise.resolve(handler(event, context, callback))
81-
.then(
82-
(result) => response(event, context, 'SUCCESS', result),
83-
(error) => response(event, context, 'FAILED', {}, error)
84-
)
85-
.then((result) => callback(null, result), callback);
80+
81+
try {
82+
const result = await handler(event, context);
83+
await response(event, context, 'SUCCESS', result);
84+
return result;
85+
} catch (error) {
86+
await response(event, context, 'FAILED', {}, error);
87+
throw error;
88+
}
8689
};
8790
}
8891

0 commit comments

Comments
 (0)