AOSSIE-Org / AOSSIE-Org/OrgExplorer

[BUG]: Unclosed IndexedDB database connections in github.js cause memory leaks

未關閉 適合新手
#216 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
JavaScript
星號
34
分支
92
平均合併
8 天 7 小時
30 天內合併 PR
12

描述

### Bug Description
In `src/services/github.js`, `openDB()` opens an IndexedDB database connection on every cached API request (`cacheGet`, `cacheSet`, `cacheClear`). However, the returned `db` handle is never closed once the transaction finishes or encounters an error.

When analyzing an organization with multiple repositories and fetching contributors, issues, and pull requests, hundreds of `IDBDatabase` connection handles remain open concurrently in the browser tab. This causes memory buildup and can trigger connection limit warnings or block database upgrades.

### Steps to Reproduce
1. Open OrgExplorer and analyze an organization with multiple repositories.
2. Open Chrome DevTools -> Application -> Storage -> IndexedDB -> `orgexplorer_cache`.
3. Observe active database connection handles persisting without closing.

### Code Context
In `src/services/github.js`:
```javascript
export async function cacheGet(key) {
try {
const db = await openDB()
return new Promise(res => {
const req = db.transaction(STORE, 'readonly').objectStore(STORE).get(key)
req.onsuccess = () => {
const r = req.result
if (!r || Date.now() - r.ts > TTL_MS) return res(null)
res(r.v)
// Missing db.close() cleanup
}
req.onerror = () => res(null)
})
} catch { return null }
}
```

By contrast, `src/services/cache.js` properly handles transaction lifecycles and calls `db.close()` on completion and error.

### Environment Details
- Location: `src/services/github.js`
- Impacted Browsers: All browsers supporting IndexedDB (Chrome, Firefox, Safari, Edge)

### Impact
High - Major feature is broken

貢獻指南

開啟貢獻指南

研究方向

Start with openDB and the cacheGet, cacheSet, and cacheClear entry points in src/services/github.js, comparing their transaction lifecycle with src/services/cache.js. Reproduce an organization analysis and inspect IndexedDB in Chrome DevTools; done means successful and failed requests no longer leave connection handles open or block database upgrades.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
github, javascript
領域
databases, frontend
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
活躍
描述清晰度
描述清楚
新手友好度
84/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。