Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable callbackWaitsForEmptyEventLoop for promise based handlers #39

Conversation

RafalSumislawski
Copy link
Member

@RafalSumislawski RafalSumislawski commented Jul 11, 2024

Our handler is always callback based. We can't follow the handler type of the user's handler, becuase we don't know it (the only way we can learn it is by invoking the handler and seeing what it returns).

Unfortunately AWS's behaviour is different for Promise and callback based handlers. It waits for eventloop to be empty in case of callback based handlers (https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/main/src/CallbackContext.js#L46). This means that wrapping a promise based handler in our handler implicitly enables that feature, leading to unindended behaviour. To solve this problem we disable the feature when the handler is promise based.

@RafalSumislawski RafalSumislawski requested review from a team and NimrodAvni78 July 11, 2024 13:13
@RafalSumislawski RafalSumislawski merged commit 0a29c0d into coralogix-nodejs-autoinstrumentation Jul 11, 2024
1 of 3 checks passed
@RafalSumislawski RafalSumislawski deleted the feature/CDS-1315-dont-wait-for-empty-eventloop branch July 11, 2024 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants