-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
Servicing-considerShiproom approval is required for the issueShiproom approval is required for the issuearea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.
Milestone
Description
Describe the bug
I'm using custom reconnectionHandler in Blazor server-side to automatically reload a page when the connection is lost (like on server restart).
When I open two pages that have some route constraints (like @page "/{Id:int}") in two different tabs and do something that causes a server restart, both tabs reload at the same time and usually at least one fails with the following exception:
Error: System.NullReferenceException: Object reference not set to an instance of an object.
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
at Microsoft.AspNetCore.Components.Routing.RouteConstraint.Parse(String template, String segment, String constraint)
at Microsoft.AspNetCore.Components.Routing.TemplateSegment.<>c__DisplayClass0_0.<.ctor>b__0(String token)
at System.Linq.Enumerable.SelectListPartitionIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.AspNetCore.Components.Routing.TemplateSegment..ctor(String template, String segment, Boolean isParameter)
at Microsoft.AspNetCore.Components.Routing.TemplateParser.ParseTemplate(String template)
at Microsoft.AspNetCore.Components.RouteTableFactory.<>c.<Create>b__4_1(String v)
at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Microsoft.AspNetCore.Components.RouteTableFactory.Create(Dictionary`2 templatesByHandler)
at Microsoft.AspNetCore.Components.RouteTableFactory.Create(IEnumerable`1 componentTypes)
at Microsoft.AspNetCore.Components.RouteTableFactory.Create(IEnumerable`1 assemblies)
at Microsoft.AspNetCore.Components.Routing.Router.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
To Reproduce
- download repo from https://github.com/jaryn-kubik/BlazorApp1 and launch the project
- open up the two example links in two different tabs
- do something that make VS rebuild the project (add something to a file and save it or whatever)
- wait a few seconds till the tabs try to automatically reload
- -> one of them should fail and throw an exception
There seems to be some race condition in the code handling constraints. If I remove the constraints and keep the route (@page "/{Id}" instead of @page "/{Id:int}") it works fine.
Further technical details
- ASP.NET Core 3.0
- Blazor server-side
Metadata
Metadata
Assignees
Labels
Servicing-considerShiproom approval is required for the issueShiproom approval is required for the issuearea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.