Azure / Azure/azure-functions-powershell-worker
[bug bash] The Core Tools hang if an error is encountered when indexing PowerShell functions
- Dominant language
- C#
- Stars
- 215
- Forks
- 61
- Avg merge
- 21h 4m
- Merged PRs (30d)
- 6
Description
The hang is probably being caused by the Functions Host, but I am adding an issue here for tracking.
TODO: Need to check with the `Python` and `NodeJs` teams to see if the same happens in their new programming models.
Repro steps:
Define a PowerShell function with a syntax issue in it, and start the Core Tools
This is my function definition in my `functions.psm1` file:
```powershell
function GenericHttpTriggerImplementation()
{
[Function()]
[OutputBinding(Type='http', Name='Response')]
param(
[InputBinding(Type='httpTrigger')]
[AdditionalInformation()] # This is the line with the issue where the binding name is missing
[AdditionalInformation(BindingName='Request', Name='authLevel', Value='anonymous')]
[AdditionalInformation(BindingName='Request', Name='methods', Value=('GET', 'POST'))]
[AdditionalInformation(BindingName='Request', Name='route', Value='')]
$Request,
$TriggerMetadata
)
}
```
The Core Tools hang even after pressing `Ctrl + C`
Core Tools output:
```
PS C:\MyFunctionApps\PSNPMBugBash> func start
Azure Functions Core Tools
Core Tools Version: 4.0.5210 Commit hash: N/A (64-bit)
Function Runtime Version: 4.21.1.20667
[2023-06-08T22:01:36.567Z] Language Worker Process exited. Pid=13800.
[2023-06-08T22:01:36.568Z] C:\Program Files\dotnet\dotnet.exe exited with code -532462766 (0xE0434352). Unhandled exception. System.Exception: Errors reported while executing Get-FunctionsMetadata cmldet. System.Management.Automation.CmdletInvocationException: The following problems exist with AdditionalInformation: \n The BindingName is missing, at Microsoft.Azure.Functions.PowerShell.SDK.WorkerIndexingHelper.IndexFunctions(DirectoryInfo baseDir, List`1& errors).
[2023-06-08T22:02:30.191Z] Requesting metadata from worker failed.
[2023-06-08T22:02:30.197Z] Microsoft.Azure.WebJobs.Script.Grpc: The operation has timed out.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the malformed function definition in functions.psm1 and reproduce it with func start using the Core Tools version and output shown. Trace the indexing failure and timeout involving the Functions Host, then verify that the malformed PowerShell function no longer leaves Core Tools hanging or unresponsive to Ctrl+C.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100