Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions host/src/FunctionsNetHost/Grpc/IncomingGrpcMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ private async Task Process(StreamingMessage msg)

if (workerConfig?.Description is null)
{
responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(new FunctionAppPayloadNotFoundException());
Logger.LogTrace($"Could not find a worker config in {envReloadRequest.FunctionAppDirectory}");
responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse();
break;
}

// function app payload which uses an older version of Microsoft.Azure.Functions.Worker package does not support specialization.
if (!workerConfig.Description.CanUsePlaceholder)
{
Logger.LogTrace("App payload uses an older version of worker package which does not support specialization.");
responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(new EnvironmentReloadNotSupportedException());
Logger.LogTrace("App payload uses an older version of Microsoft.Azure.Functions.Worker SDK which does not support placeholder.");
var e = new EnvironmentReloadNotSupportedException("This app is not using the latest version of Microsoft.Azure.Functions.Worker SDK and therefore does not leverage all performance optimizations. See https://aka.ms/azure-functions/dotnet/placeholders for more information.");
Comment thread
kshyju marked this conversation as resolved.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may not be super-important for this scenario, but there won't be a StackTrace with this without throwing it, will there? You can throw/catch the exception to capture the StackTrace correctly.

responseMessage.FunctionEnvironmentReloadResponse = BuildFailedEnvironmentReloadResponse(e);
break;
}

Expand Down Expand Up @@ -98,27 +100,37 @@ private async Task Process(StreamingMessage msg)
}
}

private static FunctionEnvironmentReloadResponse BuildFailedEnvironmentReloadResponse(Exception exception)
private static FunctionEnvironmentReloadResponse BuildFailedEnvironmentReloadResponse(Exception? exception = null)
{
var rpcException = new RpcException
{
Message = exception.ToString(),
Source = exception.Source ?? string.Empty,
StackTrace = exception.StackTrace ?? string.Empty
};

var response = new FunctionEnvironmentReloadResponse
{
Result = new StatusResult
{
Status = StatusResult.Types.Status.Failure,
Exception = rpcException
Status = StatusResult.Types.Status.Failure
}
};

response.Result.Exception = ToUserRpcException(exception);

return response;
}

internal static RpcException? ToUserRpcException(Exception? exception)
{
if (exception is null)
{
return null;
}

return new RpcException
{
Message = exception.Message,
Source = exception.Source ?? string.Empty,
StackTrace = exception.StackTrace ?? string.Empty,
Type = exception.GetType().FullName ?? string.Empty,
IsUserException = true
};
}
private static FunctionMetadataResponse BuildFunctionMetadataResponse()
{
var metadataResponse = new FunctionMetadataResponse
Expand All @@ -136,6 +148,7 @@ private static WorkerInitResponse BuildWorkerInitResponse()
{
Result = new StatusResult { Status = StatusResult.Types.Status.Success }
};
response.Capabilities[WorkerCapabilities.EnableUserCodeException] = bool.TrueString;

return response;
}
Expand Down
10 changes: 10 additions & 0 deletions host/src/FunctionsNetHost/Grpc/WorkerCapabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

namespace FunctionsNetHost.Grpc
{
internal static class WorkerCapabilities
{
internal const string EnableUserCodeException = "EnableUserCodeException";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<id>Microsoft.Azure.Functions.DotNetIsolatedNativeHost</id>
<title>Microsoft Azure Functions dotnet-isolated native host</title>
<tags>dotnet-isolated azure-functions azure</tags>
<version>1.0.1</version>
<version>1.0.2</version>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had we released 1.0.1 already?

<authors>Microsoft</authors>
<owners>Microsoft</owners>
<projectUrl>https://github.com/Azure/azure-functions-dotnet-worker</projectUrl>
Expand Down