Context.CandidateState never switches to FailedState

I am using Hangfire using SQL Server and MSMQ.

I have created a custom attribute as follows

public class CustomJobFilterAttribute : JobFilterAttribute, IElectStateFilter

and within OnStateElection(ElectStateContext context) I have a variable

var failedState = context.CandidateState as FailedState;

My method that processes the job throws an exception. The exception is visible in the Hangfire Dashboard under Failed State, but failedState variable within the attribute always remain null.

On attaching a debugger, I see that context.CandidateState is set to ProcessingState right after the exception and never to FailedState.

What I am doing wrong?

I am facing the same issue. Can you please help me here if you found the solution or work around for this ?

Thanks In Advance