Farfetch / kafkaflow

Apache Kafka .NET Framework to create applications simple to use and extend.
https://farfetch.github.io/kafkaflow/
MIT License
637 stars 110 forks source link

[Bug Report]: FileLoadException on ConsumerWorker execution is silently ignored #590

Open luispfgarces opened 3 weeks ago

luispfgarces commented 3 weeks ago

Prerequisites

Description

If the ConsumerWorker background task fails to start, it is silently ignored without any exception or logs to the KafkaFlow users.

In my particular case, the background task fails with TypeLoadException due to a missing binding redirect, leaving the background task in a faulted state - it will appear to the users as if the application is not consuming, and no middlewares will be executed.

I ended up resolving the root cause by adding a binding redirect, but I think that KafkaFlow should let the user know something has failed in order to assist troubleshooting.

Steps to reproduce

  1. Create a ASP.NET Framework web application (in my case, using .NET Framework 4.6.2)
  2. Add and configure KafkaFlow packages (I'm using version 3.0.10). Add any middlewares you want.
  3. Add Microsoft.Bcl.AsyncInterfaces version 8.0.0 to your web application.
  4. Ensure no binding redirect is added to app.config/web.config.
  5. Debug the application until reaching the ConsumerWorker.StartAsync(...).

KafkaFlow is expecting Microsoft.Bcl.AsyncInterfaces version 6.0.0, and as such will throw a TypeLoadException due to failed assembly binding.

Expected behavior

I expected that KafkaFlow would report an error through an exception or through an error log.

Actual behavior

Silently fails the background task on ConsumerWorker. After inspection on debug, the following exception is observed:

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

KafkaFlow version

3.0.10

luispfgarces commented 3 weeks ago

Adding screenshot.

image

Let me also suggest resolving this with a task continuation that verifies if this task has failed, and takes proper action after (e.g. emit an error log and setting the consumer state appropriately).