Skip to content

Commit

Permalink
Remove runtime responses once written
Browse files Browse the repository at this point in the history
Fix memory leak from build up of `ResponseContext` instances by removing them from the dictionary once used to write the `LambdaTestResponse` to the associated channel.
  • Loading branch information
martincostello committed Oct 7, 2024
1 parent 660f08b commit 845894b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/AwsLambdaTestServer/RuntimeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,11 @@ private async Task CompleteRequestChannelAsync(
bool isSuccessful,
CancellationToken cancellationToken)
{
var context = _responses[awsRequestId];
if (!_responses.TryRemove(awsRequestId, out var context))
{
throw new InvalidOperationException($"Failed to complete channel for AWS request Id {awsRequestId}.");
}

context.DurationTimer!.Stop();

Logger?.LogInformation(
Expand Down

0 comments on commit 845894b

Please sign in to comment.