[BUG]: Race condition & state tearing in multi-org explore and audit pipelines causing stale state overwrite and quota exhaustion

オープン
#427 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

@Sandeepkg123 がすでに取り組んでいます。

2026年10月30日 から。

  • #435 @Sandeepkg123 による — マージされずにクローズ
  • #437 @Sandeepkg123 による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, javascript, react

調査の方向性

Start with src/context/AppContext.jsx and src/services/github.js, tracing how explore and audit runs call fetchRepos and update state. Then inspect the existing request queue and its tests, if present. Done means superseded requests stop, queued work is discarded, and an older run cannot overwrite the active run’s state.

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

説明

bug enhancement
Bug Description

When users initiate multi-org exploration or trigger audit runs (e.g., clicking "Run Complete Analysis" or switching/re-searching organizations while an exploration pipeline is actively streaming network requests), AppContext.jsx triggers parallel un-cancellable promise chains (explore, runAudit, runAdvanceAnalytics, runFullAnalytics).

Because none of the fetch workflows in src/services/github.js and src/context/AppContext.jsx accept or propagate an AbortSignal, the following critical failures occur:

  1. State Tearing & Stale Model Overwrite:
    If a user searches for Organization A, realizes a typo, and quickly searches for Organization B, both explore() pipelines run concurrently against the GitHub REST API. Whichever promise chain resolves last (Promise.allSettled in buildAnalyticalModel) overwrites model, orgs, and totalRepo in React state. As a result, the UI displays Organization A's metrics while the search bar and URL state display Organization B (or vice versa).
  2. Quota Wastage on Navigation:
    If a user navigates between routes or kicks off runAdvanceAnalytics() followed by runAudit(), unmounted components or superseded search sessions continue greedily draining the user's finite GitHub API rate limit (5,000 req/hr authenticated or 60 req/hr unauthenticated) in the background without any abort mechanism.
  3. Ghost State & Zombie Loading Loops:
    If an earlier search encounters a rate limit or HTTP failure after a later search has already settled, the catch block of the superseded promise invokes setError() and wipes the active model with setModel(null), crashing an otherwise successful second exploration.
Steps to Reproduce
  1. Enter a large organization into the explore bar (e.g. facebook or microsoft) without a PAT.
  2. While the banner displays "Fetching organization metadata..." or "Fetching repositories...", immediately enter a different organization (e.g. google).
  3. Observe the network tab: All concurrent paginated requests for the first organization continue executing and consuming rate limit.
  4. When the first organization's promise resolves after the second, the displayed data model, contributors, and health metrics violently tear and get overwritten by the obsolete first search.
Logs and Screenshots

Lines in src/context/AppContext.jsx:
const repoRes = await Promise.allSettled(validOrgs.map(async org => {
const repos = await fetchRepos(org.login, org.public_repos, pat) // Cannot be aborted
reposPerOrg[org.login] = repos
return repos
}))

Proposed Technical Solution (Senior Architectural Fix)
  1. Pipeline Session Cancellation via AbortController:
    Introduce a mutable session reference (currentSessionAbortController = useRef(null)) within AppContext.jsx. When explore(), runAudit(), or runFullAnalytics() is triggered, any in-flight controller must immediately receive .abort() with an AbortError.
  2. Signal Propagation in HTTP Service:
    Extend fetchWithCache(url, pat, signal) in src/services/github.js to accept AbortSignal and pass it directly to the browser's native fetch(url, { headers, signal }).
  3. Throttler Queue Purging:
    Update enqueueRequest in src/services/github.js so tasks queued behind MAX_CONCURRENT_REQUESTS are pruned immediately if their associated signal is aborted, preventing backlogged obsolete requests from ever hitting the wire.
  4. State Guarding:
    Wrap state updates (setModel, setOrgs, setIssuesData, setPullsData) in generation checks (currentSessionId) to guarantee that discarded or aborted runs can never mutate active state.
Environment Details
  • OS: macOS / Linux / Windows
  • Browser: Chrome, Firefox, Safari (All browsers)
  • Application Version: v1.0.0
Impact
  • High - Major feature is broken
Code of Conduct
  • I have joined the Discord server (https://discord.gg/hjUhu33uAn) and will post updates there
  • I have searched existing issues to avoid duplicates
主要言語
JavaScript
スター
53
フォーク
187
平均マージ
18分
マージ済み PR(30日)
2

環境構築

はじめの一歩

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

AOSSIE-Org/OrgExplorer のほかの issue

AOSSIE-Org/OrgExplorer の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

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

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