Skip to content

Commit 07e9fb1

Browse files
authored
4.34.1 Hotfix (#10086)
* Ensuring non http invocation responses are not processed by IHttpProxyService (#9984) (#10085) * Release notes and patch version bump. * Bumping patch version number to 1. * Update release notes.
1 parent 01c899e commit 07e9fb1

File tree

4 files changed

+76
-8
lines changed

4 files changed

+76
-8
lines changed

build/common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<LangVersion>latest</LangVersion>
66
<MajorVersion>4</MajorVersion>
77
<MinorVersion>$(MinorVersionPrefix)34</MinorVersion>
8-
<PatchVersion>0</PatchVersion>
8+
<PatchVersion>1</PatchVersion>
99
<BuildNumber Condition="'$(BuildNumber)' == '' ">0</BuildNumber>
1010
<PreviewVersion></PreviewVersion>
1111

release_notes.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,4 @@
33
<!-- Please add your release notes in the following format:
44
- My change description (#PR)
55
-->
6-
- Update Python Worker Version to [4.28.1](https://github.com/Azure/azure-functions-python-worker/releases/tag/4.28.1)
7-
- Fixed an issue causing sporadic HTTP request failures when worker listeners were not fully initialized on first request #9954
8-
- Update Node.js Worker Version to [3.10.0](https://github.com/Azure/azure-functions-nodejs-worker/releases/tag/v3.10.0) (#9999)
9-
- Update PowerShell worker 7.2 to [4.0.3220](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3220)
10-
- Update PowerShell worker 7.4 to [4.0.3219](https://github.com/Azure/azure-functions-powershell-worker/releases/tag/v4.0.3219)
11-
- Update Azure.Identity to 1.11.0 (#10002)
6+
- Ensuring non http invocation responses are not processed by IHttpProxyService (#10085)

src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ internal async Task InvokeResponse(InvocationResponse invokeResponse)
10941094

10951095
try
10961096
{
1097-
if (IsHttpProxyingWorker)
1097+
if (IsHttpProxyingWorker && context.FunctionMetadata.IsHttpTriggerFunction())
10981098
{
10991099
await _httpProxyService.EnsureSuccessfulForwardingAsync(context);
11001100
}

test/WebJobs.Script.Tests/Workers/Rpc/GrpcWorkerChannelTests.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,35 @@ public async Task GetFunctionMetadata_MultipleCalls_ReturnSameTask()
13961396
Assert.Same(functionsTask1, functionsTask2);
13971397
}
13981398

1399+
[Fact]
1400+
public async Task Ensure_SuccessfulForwardingAsync_Is_Invoked_OnlyFor_HttpInvocationResponses()
1401+
{
1402+
await CreateDefaultWorkerChannel(capabilities: new Dictionary<string, string>() { { RpcWorkerConstants.HttpUri, "http://localhost:1234" } });
1403+
1404+
var httpInvocationId = Guid.NewGuid();
1405+
ScriptInvocationContext httpInvocationContext = GetTestScriptInvocationContext(httpInvocationId, new TaskCompletionSource<ScriptInvocationResult>(), logger: _logger);
1406+
httpInvocationContext.FunctionMetadata = BuildFunctionMetadataForHttpTrigger("httpTrigger");
1407+
1408+
var timerInvocationId = Guid.NewGuid();
1409+
ScriptInvocationContext timerInvocationContext = GetTestScriptInvocationContext(timerInvocationId, new TaskCompletionSource<ScriptInvocationResult>(), logger: _logger);
1410+
timerInvocationContext.FunctionMetadata = BuildFunctionMetadataForTimerTrigger("timerTrigger");
1411+
1412+
// Send http trigger and timer trigger invocation invocation requests.
1413+
await _workerChannel.SendInvocationRequest(httpInvocationContext);
1414+
await _workerChannel.SendInvocationRequest(timerInvocationContext);
1415+
1416+
// Send http trigger and timer trigger invocation responses.
1417+
await _workerChannel.InvokeResponse(BuildSuccessfulInvocationResponse(timerInvocationId.ToString()));
1418+
await _workerChannel.InvokeResponse(BuildSuccessfulInvocationResponse(httpInvocationId.ToString()));
1419+
1420+
var logs = _logger.GetLogMessages().ToArray();
1421+
Assert.Single(logs.Where(m => m.FormattedMessage.Contains($"InvocationResponse received for invocation: '{timerInvocationId}'")));
1422+
Assert.Single(logs.Where(m => m.FormattedMessage.Contains($"InvocationResponse received for invocation: '{httpInvocationId}'")));
1423+
1424+
// IHttpProxyService.EnsureSuccessfulForwardingAsync method should be invoked only for http invocation response.
1425+
_mockHttpProxyService.Verify(m => m.EnsureSuccessfulForwardingAsync(It.IsAny<ScriptInvocationContext>()), Times.Once);
1426+
}
1427+
13991428
[Fact]
14001429
public async Task Log_And_InvocationResult_OrderedCorrectly()
14011430
{
@@ -1574,5 +1603,49 @@ private Task CreateSharedMemoryEnabledWorkerChannel(bool setEnvironmentVariable
15741603
// Send worker init request and enable the capabilities
15751604
return CreateDefaultWorkerChannel(capabilities: capabilities);
15761605
}
1606+
1607+
private static InvocationResponse BuildSuccessfulInvocationResponse(string invocationId)
1608+
{
1609+
return new InvocationResponse
1610+
{
1611+
InvocationId = invocationId,
1612+
Result = new StatusResult
1613+
{
1614+
Status = StatusResult.Types.Status.Success
1615+
},
1616+
};
1617+
}
1618+
1619+
private static FunctionMetadata BuildFunctionMetadataForHttpTrigger(string name, string language = null)
1620+
{
1621+
var functionMetadata = new FunctionMetadata() { Name = name, Language = language };
1622+
functionMetadata.Bindings.Add(new BindingMetadata()
1623+
{
1624+
Type = "httpTrigger",
1625+
Direction = BindingDirection.In,
1626+
Name = "req"
1627+
});
1628+
functionMetadata.Bindings.Add(new BindingMetadata()
1629+
{
1630+
Type = "http",
1631+
Direction = BindingDirection.Out,
1632+
Name = "$return"
1633+
});
1634+
1635+
return functionMetadata;
1636+
}
1637+
1638+
private static FunctionMetadata BuildFunctionMetadataForTimerTrigger(string name, string language = null)
1639+
{
1640+
var functionMetadata = new FunctionMetadata() { Name = name, Language = language };
1641+
functionMetadata.Bindings.Add(new BindingMetadata()
1642+
{
1643+
Type = "timerTrigger",
1644+
Direction = BindingDirection.In,
1645+
Name = "myTimer"
1646+
});
1647+
1648+
return functionMetadata;
1649+
}
15771650
}
15781651
}

0 commit comments

Comments
 (0)