Azure / azure-webjobs-sdk-extensions

Azure WebJobs SDK Extensions
MIT License
342 stars 205 forks source link

Lease encountered an unhandled user exception during processing and cosmosdbtrigger invocations failing #892

Open Barsonax opened 4 months ago

Barsonax commented 4 months ago

Repro steps

Seems to happen randomly when using CosmosDbTriggers. When it happens it usually happens in a burst of warnings

Expected behavior

The cosmosdbtrigger invocation should work without errors.

Actual behavior

A 'Lease 0 encountered an unhandled user exception during processing.' warning is logged and the cosmosdbtrigger invocation fails.

Known workarounds

No workarounds that I know of

Related information

image

ealsur commented 4 months ago

This log means your Function code had an unhandled error. Look at the Exception property and that should tell you the error that happened during execution.

This error is happening after the Trigger received the events and sent them to your Function code for execution.

Barsonax commented 4 months ago

There is no exception property so that makes it hard to find out the cause of this. Should there be an exception property normally?

I do see this behavior happening from multiple cosmosdb triggers at the same time. I don't see any logging from my own code so I think it does not even enter my code but already errors before that.

Maybe implementing my own middleware to catch the error and log it would give me more information

ealsur commented 4 months ago

The extension emits the event with the Exception property populated:

https://github.com/Azure/azure-webjobs-sdk-extensions/blob/eae7c4c5f8ed6441e661f291f532b8051f3605e7/src/WebJobs.Extensions.CosmosDB/Trigger/CosmosDBTriggerHealthMonitor.cs#L26

It could be that Application Insights is storing them on the exceptions table.