Skip to content

Default behaviour unhandled rejections

0

Hello AWS,

After some good testing we moved our production Lambdas to Node 10.x runtime at May 15th. All seemed to be fine, except that conclusion changed on May 29th. From that day on (without changing any Lambda) we had an issues with one of our production Lambdas that exited on a unhandled promise rejection that didnt happen before.

The NodeJS Foundation did not make a breaking change regarding unhandled promise rejections and we tested it on Node 10.x and all seemed fine (before 29th of May). So it came to us as a surprise when suddenly it wasnt giving a warning anymore but instead throws an error.

After some searching we had to conclude that the only reason this could happen is because AWS added code to the runtime outside of our control, similar to this:

process.on('unhandledRejection', () => {
    throw new Error('some error');
});

This change really affected our business and could have had worse result than it did. Can AWS confirm that this is indeed the case?

When its indeed the case we would like to ask AWS to offer such changes differently in the future. We keep track of changes in NodeJS releases and make decisions based on that. We do not prefer auto minor updates as is the case since Node 10.x runtime, but when AWS is performing runtime changes that easy without announcing it long before it will take into effect, we feel not very secure using the built-in runtimes of Lambda.

It is my hope AWS can confirm this and also elaborate on the changes made around the 29th of May.

asked 7 years ago1.5K views

2 Answers
0

When running the code sample provided in a local environment compared to running it in a Lambda environment, there is indeed a discrepancy between the way Node operates. NodeJs 10.x will return a warning regarding the unhandled promise rejection without failing the entire execution whereas Lambda will fail when the unhandled promise rejection warning is returned. This is the expected behavior for Lambda functions running NodeJS 10.x. Currently the best course of action it to be aware of this discrepancy and handle it accordingly in your function code. The potential implications of this issue have been raised and are being reviewed.

AWS

answered 7 years ago

0

This is a follow-up to the previous message.

When we upgrade versions of Lambda runtimes, we strive to maintain compatibility through the upgrade. However, sometimes these updates result in breaking changes that are aligned with the general guidelines of the language. Unhandled promise rejections have been deprecated by Node and the language has plans to terminate the Node.js process with a non-zero exit code in the future. The NodeJS 10 runtime is aligned with this direction and the prevailing opinion of the Node community is that unhandled rejections typically represent a serious bug. We realize that this change may affect specific customer functions. As a workaround you can try to remove listeners for unhandled promise rejections by calling process.removeAllListeners('unhandledRejection');

We apologize for the inconvenience that this change will cause for you. As a result of your feedback, we are evaluating ways by which we can communicate these changes better in the future.

AWS

answered 7 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.