Skip to content

Commit

Permalink
πŸ› Fixed JSDisconnectedException thrown on blazor server (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
meenzen authored Jul 31, 2024
1 parent 9c49610 commit 3209bb4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/BlazorTurnstile/Turnstile.razor
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,20 @@
{
if (_interop != null)
{
await _interop.DisposeAsync();
try
{
if (WidgetId != null)
{
await _interop.RemoveAsync(WidgetId);
WidgetId = null;
}

if (WidgetId != null)
await _interop.DisposeAsync();
}
catch (JSDisconnectedException)
{
await _interop.RemoveAsync(WidgetId);
WidgetId = null;
// this exception may be thrown when closing or reloading the page on blazor server
// it is safe to ignore
}
}

Expand Down

0 comments on commit 3209bb4

Please sign in to comment.