bug: CommandBar.runOnAsyncThread can hang forever when reading TNote bridge fields
@EduardMe 已經在處理了。
開始於 2026年10月28日。
評估
這個 Issue 還沒有評估資料。
描述
Summary
CommandBar.runOnAsyncThread() (NotePlan 3.21.3+) can leave its Promise unresolved forever when the sync callback reads live NotePlan note objects (TNote / note.content / note.paragraphs / frontmatter) via the plugin bridge. Plugin code that awaits the result never resumes, so finally cleanup (e.g. CommandBar.showLoading(false)) never runs and UI progress dialogs stay stuck.
We have now hit this twice in np.Shared cache rebuilds.
Observed behaviour
1. Tag / mention cache (Dashboard install rebuild)
User vault ~1667 calendar + ~4844 regular notes. Dashboard onUpdateOrInstall forced a tag/mention cache rebuild, which scans notes inside runOnAsyncThread via our helper runSyncWorkOnAsyncThread.
Log sequence:
generateTagMentionCache :: - processing 1667 calendar + 4844 regular notes ...
generateTagMentionCache :: - scanning 1667 calendar notes ...
runSyncWorkOnAsyncThread :: generateTagMentionCache calendar: starting on async thread
Then nothing: no async thread finished, no completion / error path, no showLoading(false).
Progress UI (CommandBar.showLoading) updated every 100 notes and stuck at:
Generating tag/mention cache: reading calendar note 1600/1667
(That count only means note 1600 was reached; the next UI tick would be 1700. Hang is somewhere after that progress update -- later notes and/or returning from the async callback.)
Meanwhile the main plugin thread kept accepting other Dashboard work (windowReload, showDashboardReact, section refreshes), which is consistent with the background job never completing while onUpdateOrInstall stayed parked on await generateTagMentionCache(...).
2. Notes-changed-recently cache (earlier, same API)
Reading a few TNote fields inside runOnAsyncThread during generate/update left Projects Refresh spinning indefinitely. We worked around it in np.Shared 1.3.1 by keeping that cache on the main thread, with comments documenting that bridge field reads inside the async API hung the Promise live.
What we already ruled out / worked around on the plugin side
- Returning large objects from the async callback previously also hung the Promise (scan finished,
awaitnever resumed). Tag/mention cache now only returns a primitive (true) and stores results in outer variables. That did not prevent this hang. CommandBar.showLoadingfrom inside the callback is documented as allowed and did update for a long time before the hang.- This does not look like a simple "vault too big / slow" case: progress advanced through ~1600 notes, then the Promise never settled.
Ask
Please confirm whether reading live note bridge objects from CommandBar.runOnAsyncThread is unsupported, or whether this is a platform bug.
If unsupported, docs should say so explicitly (safe work = plain data only; gather TNote fields on the main thread first).
If supported, we need the Promise to always settle (resolve or reject) even when note-field reads fail or deadlock, so plugins can clear loading UI and recover.
Workaround plugins are using
Until this is reliable, Shared Resources will avoid runOnAsyncThread for loops that read live TNote fields (main-thread scan + showLoading progress), same as the notes-changed-recently cache.
Environment
- API:
CommandBar.runOnAsyncThread(feature gated from 3.21.3) - Plugins:
np.Sharedtag/mention cache + DashboardonUpdateOrInstallforced rebuild - Repro scale: ~6.5k notes in the reported vault
- 主要語言
- JavaScript
- 星號
- 203
- 分支
- 81
- 平均合併
- 52 分鐘
- 30 天內合併 PR
- 1
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
NotePlan/plugins 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
-
the todaystart command fails silently if you are working in a split可能已有人在做 @jgclark 於 1 天前認領。 未關閉bug
-
API bug
難度 4/5 3-5 天 新手友好度 45/100
-
Task Sorting & Tools: support other line types可能已有人在做 @dwertheimer 於 12 天前認領。 未關閉enhancement
-
getFoldersMatching adds root "/" even when it is not an inclusion可能已有人在做 @jgclark 於 12 天前認領。 未關閉
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
-
help wanted
難度 2/5 1-3 小時 新手友好度 77/100
Aethelgard-Systems/agent-postbox#32 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
SamuelNDCE/plume#42 ·
維護者通常 1 天內回覆
-
[UI] Theme Provider Props table overflows on mobile viewports可能已有人在做 @SajanBisht 今天認領。 未關閉framework/gatsby help wanted kind/bug
難度 2/5 1-3 小時 新手友好度 78/100
layer5io/layer5#8264 · 1 則留言 ·
維護者通常 3 天內回覆