Belemetry: closing a circuit while BelemetryJsBridge starts throws ObjectDisposedException

オープン 初心者向け
#15,455 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp
領域
frontend

調査の方向性

src/Utilities/Belemetry/Bit.Belemetry/Interop/BelemetryJsBridge.cs を開き、StartAsync を DisposeAsync と併せて読んでください。ロックは StartAsync の先頭で取得され、import、start、attachDotNet、SynchronizeAsync の間保持され、finally で解放され、DisposeAsync の最後で破棄されます。issue が提案する 2 つの修正のうち 1 つを選んでください — _startLock の破棄をやめる、または Release() を _disposed フラグでガードする — そして既存のキャンセル処理をそのまま維持してください。完了とは、起動途中で閉じる Blazor Server ページが StartAsync から ObjectDisposedException をログに出さなくなることを意味します。

索引モデルが issue の本文から書いたものです。

説明

When a Blazor Server circuit is disposed while BelemetryJsBridge.StartAsync is still awaiting its JS interop calls, the finally block calls _startLock.Release() on a SemaphoreSlim that DisposeAsync has already disposed:

System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Threading.SemaphoreSlim'.
   at System.Threading.SemaphoreSlim.Release()
   at Bit.Belemetry.BelemetryJsBridge.StartAsync()
   at Bit.Belemetry.BelemetryInitializer.OnAfterRenderAsync(Boolean firstRender)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(...)
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit '...'.

It is logged as an unhandled exception in the circuit. Nothing else breaks, since the circuit is going away anyway, but it shows up as an error every time a tab closes during startup.

Where: src/Utilities/Belemetry/Bit.Belemetry/Interop/BelemetryJsBridge.cs: StartAsync holds _startLock across import, start, attachDotNet and SynchronizeAsync; DisposeAsync ends with _startLock.Dispose().

Fix: don't dispose _startLock in DisposeAsync (a SemaphoreSlim that never had its AvailableWaitHandle read holds nothing that needs disposing), or have StartAsync's finally skip Release() once _disposed is set.

Repro: open a page with BelemetryInitializer on Blazor Server and close the tab while it starts (a slow network makes the window wide).

主要言語
C#
スター
1.4k
フォーク
264
平均マージ
8時間 5分
マージ済み PR(30日)
595

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bitfoundation/bitplatform のほかの issue

bitfoundation/bitplatform の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。