Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception in circuit #39

Open
Alerinos opened this issue Dec 10, 2022 · 4 comments
Open

Unhandled exception in circuit #39

Alerinos opened this issue Dec 10, 2022 · 4 comments

Comments

@Alerinos
Copy link

Alerinos commented Dec 10, 2022

Hi, I have some problem with the application.
There is probably something looping in the nginx configuration that caused the application to get ddos/flood.

I got error 500 status probably because of this error.

It could be caused by something else but I figured I'd report the issue.

Json error:

{"Timestamp":"2022-12-10T09:22:18.5782563+01:00","Level":"Error","MessageTemplate":"Unhandled exception in circuit '{CircuitId}'.","RenderedMessage":"Unhandled exception in circuit '\"UPcusR1_t3zFRYb5laCQXsZwm6hJzBtpeFrz52Zy4MU\"'.","Exception":"Microsoft.JSInterop.JSDisconnectedException: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.\n   at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)\n   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args)\n   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)\n   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)\n   at Microsoft.JSInterop.Implementation.JSObjectReference.DisposeAsync()\n   at Toolbelt.Blazor.HeadElement.HeadElementHelperService.EnsureScriptEnabledAsync[T]()\n   at Toolbelt.Blazor.HeadElement.HeadElementHelperService.InvokeJSAsync[T](String identifier, Object[] args)\n   at Toolbelt.Blazor.HeadElement.HeadElementHelperService.GetDefaultTitleAsync()\n   at Toolbelt.Blazor.HeadElement.HeadElementHelperService.GetDefaultsAsync()\n   at Toolbelt.Blazor.HeadElement.HeadElementHelperService.ResetIfNeededAsync()\n   at Toolbelt.Blazor.HeadElement.HeadElementHelperService.SetTitleAsync(String title)\n   at Stand.Libraries.Website.AppState.Head.SetTitleAsync(String title) in C:\\Git\\Stand\\Source\\Libraries\\Stand.Libraries.Website\\AppState\\Head.cs:line 24\n   at Grajse.Areas.Web.Pages.Index.OnInitializedAsync() in C:\\Git\\Stand\\Source\\Projects\\Grajse\\Areas\\Web\\Pages\\Index.razor:line 56\n   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()\n   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)","Properties":{"CircuitId":"UPcusR1_t3zFRYb5laCQXsZwm6hJzBtpeFrz52Zy4MU","EventId":{"Id":111,"Name":"CircuitUnhandledException"},"SourceContext":"Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost","TransportConnectionId":"a53Zn0DqAw0MWHbf5vYLrw","RequestId":"0HMMQGRTPT3J1:00000001","RequestPath":"/_blazor","ConnectionId":"0HMMQGRTPT3J1"}}

Parse error:

{
"Timestamp":"2022-12-10T09:22:18.5782563+01:00",
"Level":"Error",
"MessageTemplate":"Unhandled exception in circuit '{CircuitId}'.",
"RenderedMessage":"Unhandled exception in circuit '\"UPcusR1_t3zFRYb5laCQXsZwm6hJzBtpeFrz52Zy4MU\"'.",
"Exception":"Microsoft.JSInterop.JSDisconnectedException: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.\n at 
Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId)\n at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args)\n at 
Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)\n at 
Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)\n at 
Microsoft.JSInterop.Implementation.JSObjectReference.DisposeAsync()\n at 
Toolbelt.Blazor.HeadElement.HeadElementHelperService.EnsureScriptEnabledAsync[T]()\n at 
Toolbelt.Blazor.HeadElement.HeadElementHelperService.InvokeJSAsync[T](String identifier, Object[] args)\n at 
Toolbelt.Blazor.HeadElement.HeadElementHelperService.GetDefaultTitleAsync()\n at 
Toolbelt.Blazor.HeadElement.HeadElementHelperService.GetDefaultsAsync()\n at 
Toolbelt.Blazor.HeadElement.HeadElementHelperService.ResetIfNeededAsync()\n at 
Toolbelt.Blazor.HeadElement.HeadElementHelperService.SetTitleAsync(String title)\n at 
Stand.Libraries.Website.AppState.Head.SetTitleAsync(String title) in 
C:\\Git\\Stand\\Source\\Libraries\\Stand.Libraries.Website\\AppState\\Head.cs:line 24\n at 
Grajse.Areas.Web.Pages.Index.OnInitializedAsync() in 
C:\\Git\\Stand\\Source\\Projects\\Grajse\\Areas\\Web\\Pages\\Index.razor:line 56\n at 
Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()\n at 
Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState 
owningComponentState)",

"Properties":{
"CircuitId":"UPcusR1_t3zFRYb5laCQXsZwm6hJzBtpeFrz52Zy4MU",
"EventId":{
"Id":111,
"Name":"CircuitUnhandledException"
},
"SourceContext":"Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost",
"TransportConnectionId":"a53Zn0DqAw0MWHbf5vYLrw",
"RequestId":"0HMMQGRTPT3J1:00000001",
"RequestPath":"/_blazor",
"ConnectionId":"0HMMQGRTPT3J1"
}
}

my provider:

namespace Stand.Libraries.Website.AppState;

public class Head
{
    public readonly IHeadElementHelper _headElementHelper;

    public List<MetaElement> MetaElements = new();
    public List<LinkElement> LinkElements = new();

    public static string? TitlePrefix { get; set; }

    public Head(IHeadElementHelper HeadElementHelper)
        => _headElementHelper = HeadElementHelper;

    public async Task SetTitleAsync(string title)
        => await _headElementHelper.SetTitleAsync($"{TitlePrefix}{title}");

    public async Task SetDescriptionAsync(string description)
        => await _headElementHelper.SetMetaElementsAsync(
            ByName("description", description)
        );

    public async Task SetMetaAsync(string property, string content)
        => await _headElementHelper.SetMetaElementsAsync(
            ByProp(property, content)
        );

    public async Task SetLinkAsync(List<Link> links)
    {
        links.ForEach(x => LinkElements.Add(new LinkElement(x.Rel, x.Href)));   
        await _headElementHelper.SetLinkElementsAsync(LinkElements.ToArray());
    }
        
    
    public async Task SetMetaAsync(List<Meta> metas)
    {
        var element = new List<MetaElement>();
        metas.ForEach(x => element.Add(ByProp(x.Property, x.Content)));
        await _headElementHelper.SetMetaElementsAsync(element.ToArray());
    }

    public class Meta
    {
        public string Property { get; set; } = string.Empty;
        public string Content { get; set; } = string.Empty;
    }

    public class Link
    {
        public string Rel { get; set; } = string.Empty;
        public string Href { get; set; } = string.Empty;
    }

}

Index:

    protected override async Task OnInitializedAsync()
        => await Head.SetTitleAsync(Culture.Translate("Home Page"));

Details of my problem described elsewhere:
dotnet/aspnetcore#45522 (comment)

@jsakamoto
Copy link
Owner

@Alerinos Could you try the latest version?

I hope the commit below fixes the problem.

@Alerinos
Copy link
Author

@jsakamoto Thank you for the quick fix, unfortunately this is a difficult bug to trigger due to the large number of users and ddos attack. I'll let you know if it happens again, thanks again.

@mysteryx93
Copy link

mysteryx93 commented Mar 2, 2023

I'm also getting this error when publishing the app on the server with .NET 7 and all packages updated. It works locally but I'm unable to deploy on Ubuntu.

Microsoft.JSInterop.JSDisconnectedException: JavaScript interop calls cannot be issued at this time. This is because the circuit has disconnected and is being disposed.
Mar 02 20:06:00 localhost kestrel-store[5806]: Unhandled exception in circuit 'Z91CCAci1dQxIe0FpYEmGdDetGmo6AVhTCMJw_QYo48'.
Mar 02 20:06:00 localhost kestrel-store[5806]: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]

@mysteryx93
Copy link

Found my problem, there are files to deploy under wwwroot/_content, copied those and it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants