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

Cancel timeout when it is no longer needed #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wheineman-sunrun
Copy link

@wheineman-sunrun wheineman-sunrun commented Jan 4, 2024

Once the fetch request completes, it is no longer necessary to wait for the timeout. Cancel it to clear the async stack

This is specifically an issue when using this library from within an AWS lambda, as the default handling waits for an empty event loop before allowing the lambda to complete.

callbackWaitsForEmptyEventLoop – Set to false to send the response right away when the callback runs, instead of waiting for the Node.js event loop to be empty. If this is false, any outstanding events continue to run during the next invocation.

https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html

This seemed like a quick change that would be correct for other runtime environments, so I submitted this PR.

Once the fetch request completes, it is no longer necessary to wait for the timeout. Cancel it to clear the async stack
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.

None yet

3 participants