12 · Troubleshooting

Every RFEVT diagnostic and the most common runtime mistakes

Build diagnostics

The analyzer that ships with the package reports these. Errors stop the build. Warnings and info point at likely bugs.

IDSeverityMessage (short)Fix
RFEVT001ErrorAttribute used in a .razor @code blockMove the member to the .razor.cs code-behind. The generator can't see code inside .razor files.
RFEVT002ErrorType (or a containing type) isn't partialAdd partial to the class and to any class it's nested in
RFEVT003ErrorType doesn't derive from RfEventComponentAdd @inherits RfEventComponent to the .razor file (or : RfEventComponent for a C#-only component)
RFEVT004ErrorInvalid [Subscribe] signatureUse void M(E), Task/ValueTask M(E), or Task/ValueTask M(E, CancellationToken). Non-static, non-generic, no ref/out.
RFEVT005ErrorHandler's first parameter isn't an IEventMake the type implement IEvent, or fix the parameter type
RFEVT006Error[UseState] property isn't a partial get-only declarationWrite it as private partial T Name { get; }, non-static and without a body
RFEVT007Error[UseState] property type isn't a state typeUse a type implementing IState<T>, or add Select = …
RFEVT008ErrorInvalid selectorstatic TProperty Select(TState state) in the same class. Tuple names may differ.
RFEVT009ErrorAttributes and a RegisterSubscriptions overrideMove the manual code into partial void OnRegisterSubscriptions(SubscriptionBuilder builder)
RFEVT010WarningInconsistent Scope/ScopeNameUse either Scope = ScopeKind.Root or ScopeName = "x", not both
RFEVT011WarningTwo handlers for the same event in one componentMerge them. Both would run.
RFEVT012InfoEvent type isn't immutableUse a record with init-only properties
RFEVT013WarningState type isn't a recordUse a record, so equal values don't re-render everything
RFEVT014WarningComponent implements IDisposable/IAsyncDisposable itselfOverride DisposeAsyncCore instead

Compiler errors you may see alongside them:

ErrorMeaning
CS0263 (different base classes)Base class declared in the code-behind but not in the .razor file. Add @inherits RfEventComponent.
CS9248 (partial property must have an implementation part)The generator didn't run. The project containing the component needs its own RForge.Blazor.Events package reference, because analyzers don't flow through project references (setup step 2).

Runtime problems

"My component doesn't update"

Check in this order:

  1. Does it read the state through [UseState] (or a handle)? State<T>().Value in markup is a one-off read with no subscription.
  2. Is the state replaced rather than mutated? Update(s => s with { … }) notifies. s.Items.Add(…) on a mutable list doesn't.
  3. Does a selector return the same value? Then not re-rendering is correct.
  4. Is the writer in a different render mode (Server vs. WebAssembly island)? Different modes use different hubs (tutorial 09).
  5. For events: was the handler mounted before the publish? Events aren't replayed.

"My handler never runs"

  • The listener is inside an EventScope/StateScope and the event was published from outside it. Publishes bubble up, not down into other scopes. Publish with Route.Global, or listen with [Subscribe(Scope = ScopeKind.Root)] (tutorial 05).
  • The publish used Route.Local or Route.Broadcast from a scope the listener isn't in.
  • The listener's component is rendered in a different render mode from the publisher.

Exceptions

ExceptionCauseFix
RfEventScopeNotFoundExceptionRoute.Named("x") or ScopeName = "x" with no enclosing scope named xCheck the name, and that the component is inside that scope
RfEventReentrancyExceptionHandlers publish events that trigger each other (A → B → A …)Break the loop, or skip publishing when nothing changed
ObjectDisposedException from the hubUsing a scope or store after its component/circuit ended (often a timer)Stop background work on dispose. Catch it in timer callbacks.
InvalidOperationException: SubscriptionBuilder can only be used inside RegisterSubscriptionsThe builder was stored and used laterUse Scope.Subscribe (tutorial 10)
No registered service of type 'RForge.Blazor.Events.IRfEventHub'AddRForgeEvents missing in this host (often the WebAssembly client)Register in both Program.cs files
MissingRendererInfoException (tests)bUnit needs SetRendererInfoSee tutorial 11

Other surprises

SurpriseExplanation
One user sees another user's data on ServerA service holding IRfEventHub is registered as Singleton. Make it Scoped.
Changing StateScope's Initial parameter does nothingIt's read once (a warning is logged). Write to the store.
A StateScope breaks Route.LocalA StateScope is also a scope: inside it, "local" means the StateScope
State resets when an Auto page later runs in WebAssemblyNew runtime, new hub. Reload from the source.
State loaded during prerender disappearsNot opted into persistence (tutorial 08)
A click feels slowA handler awaits long work. Delivery is sequential, so fire and forget.
Analyzer errors don't appear, only compiler errorsThe C# compiler skips analyzers when other compile errors exist. Fix those first and the RFEVT errors will show.

Still stuck?

An unhandled error has occurred. Reload 🗙