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

Fix test tool hanging when restarting debugging session. #1925

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

normj
Copy link
Member

@normj normj commented Jan 8, 2025

Description of changes:
In the test tool if a user starts debugging their Lambda function, then stops debugging without letting the function finish it puts the test tool in hanging situation when the debug session is restarted. This happens because the first debug session never told the test tool that it was done processing the event so the test tool thinks the event is still active and executing. When the debug session is restarted and the GetNextInvocation is called it blocks waiting for the event to finish.

In the real Lambda environment the GetNextInvocation would never be called till the event is done processing. So when in the GetNextInvocation there should never be an active event still executing. For the test tool we will assume that if there is an active event with its status as executing that this is a debug restart scenario and resend the event to be debugged again.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@normj normj requested review from philasmar and gcbeattyAWS January 8, 2025 00:51
Copy link
Contributor

@gcbeattyAWS gcbeattyAWS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a general question. how does the lambda function/runtime know whether it should be calling either the GetNextInvocationDefaultFunction url vs calling the GetNextInvocation url? i assume if multiple lambdas are running at the same time they will use the url with their function name. in what case would the other url be called?

        app.MapGet("/2018-06-01/runtime/invocation/next", GetNextInvocationDefaultFunction);
        app.MapGet("/{functionName}/2018-06-01/runtime/invocation/next", GetNextInvocation);

@normj
Copy link
Member Author

normj commented Jan 8, 2025

just a general question. how does the lambda function/runtime know whether it should be calling either the GetNextInvocationDefaultFunction url vs calling the GetNextInvocation url? i assume if multiple lambdas are running at the same time they will use the url with their function name. in what case would the other url be called?

        app.MapGet("/2018-06-01/runtime/invocation/next", GetNextInvocationDefaultFunction);
        app.MapGet("/{functionName}/2018-06-01/runtime/invocation/next", GetNextInvocation);

In the Lambda function if the AWS_LAMBDA_RUNTIME_API environment variable is set to localhost:<port> it will go to GetNextInvocationDefaultFunction. That is how we direct users in the current test tool which isn't designed for multiple functions. If you set AWS_LAMBDA_RUNTIME_API to localhost:<port>/<function-name> then it will go to GetNextInvocation. When we get to the Aspire integration we will set the environment this way.

@normj normj force-pushed the normj/fix-redebug-testtool-v2 branch from ef143c3 to f8577af Compare January 8, 2025 17:50
@normj normj merged commit f8577af into feature/lambdatesttool-v2 Jan 9, 2025
6 checks passed
@normj normj deleted the normj/fix-redebug-testtool-v2 branch January 14, 2025 20:49
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.

3 participants