問題
的 包含 5 個同步 I/O,每次 plugin 啟動()都會觸發,直接 block event loop。
觸發時機
每次 被呼叫(等於 plugin 啟動),一定執行這段 sync blocking code。
與 Issue #763 的關係
| 項目 |
Issue #763(P3) |
本 Issue |
| Sync I/O 位置 |
內部(store.ts:215-238) |
(store.ts:142-189) |
| 觸發時機 |
每次 / 等 write operation |
每次 (plugin init) |
| 影响的 operation |
所有 7 個 call sites |
Plugin 啟動 + 所有後續 operation |
| PR #794 修復 |
✅ 是(PR #794 的目標) |
❌ 否(scope 外) |
三個問題的層次關係:
為何被遺漏
PR #794(P3 async file lock)的 scope 僅限於 內部的 5 個 sync I/O。
在 之前執行,不屬於 P3 修復範圍。
修復方向
1. →
2. Call site 更新()
是 sync API,無法直接 await。修復方式:fire-and-forget +
3. 確認其他 call site
搜尋確認只有 一個 call site:
src/store.ts:142:export function validateStoragePath(dbPath: string): string {
index.ts:23:import { MemoryStore, validateStoragePath } from "./src/store.js";
index.ts:1934: validateStoragePath(resolvedDbPath);
驗證方式
- 確認 改為 ,無 變體殘留
- 確認所有 call site 使用 或 fire-and-forget 方式
- 全域搜尋確保無其他地方 still 使用 sync 版本:
9: existsSync,
10: accessSync,
12: mkdirSync,
13: realpathSync,
14: lstatSync,
147: const stats = lstatSync(dbPath);
150: resolvedPath = realpathSync(dbPath);
174: if (!existsSync(resolvedPath)) {
176: mkdirSync(resolvedPath, { recursive: true });
189: accessSync(resolvedPath, constants.W_OK);
247: if (!existsSync(lockPath)) {
248: try { mkdirSync(dirname(lockPath), { recursive: true }); } catch {}
261: if (existsSync(lockPath)) {
- Plugin init 時無 blocking I/O,event loop 不被卡住
Priority
| 等級 |
理由 |
| HIGH |
Plugin init 必觸發,影響所有後續 operation |
| MEDIUM |
高併發場景下是效能瓶頸 |
關聯 Issue
| Issue |
關聯 |
| #763 |
父 issue,P3 section 只含 內部 sync(不包含本 issue) |
| #788 |
Redis lock,無關 |
| #794 |
P3 async file lock,修復 內部(不同範圍) |
問題
的 包含 5 個同步 I/O,每次 plugin 啟動()都會觸發,直接 block event loop。
觸發時機
每次 被呼叫(等於 plugin 啟動),一定執行這段 sync blocking code。
與 Issue #763 的關係
三個問題的層次關係:
為何被遺漏
PR #794(P3 async file lock)的 scope 僅限於 內部的 5 個 sync I/O。
在 之前執行,不屬於 P3 修復範圍。
修復方向
1. →
2. Call site 更新()
是 sync API,無法直接 await。修復方式:fire-and-forget +
3. 確認其他 call site
搜尋確認只有 一個 call site:
src/store.ts:142:export function validateStoragePath(dbPath: string): string {
index.ts:23:import { MemoryStore, validateStoragePath } from "./src/store.js";
index.ts:1934: validateStoragePath(resolvedDbPath);
驗證方式
9: existsSync,
10: accessSync,
12: mkdirSync,
13: realpathSync,
14: lstatSync,
147: const stats = lstatSync(dbPath);
150: resolvedPath = realpathSync(dbPath);
174: if (!existsSync(resolvedPath)) {
176: mkdirSync(resolvedPath, { recursive: true });
189: accessSync(resolvedPath, constants.W_OK);
247: if (!existsSync(lockPath)) {
248: try { mkdirSync(dirname(lockPath), { recursive: true }); } catch {}
261: if (existsSync(lockPath)) {
Priority
關聯 Issue