Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

bug: CommandBar.runOnAsyncThread can hang forever when reading TNote bridge fields

Aperta
#793 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@EduardMe ci sta già lavorando.

Dal 28/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

bug

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, await never resumed). Tag/mention cache now only returns a primitive (true) and stores results in outer variables. That did not prevent this hang.
  • CommandBar.showLoading from 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.Shared tag/mention cache + Dashboard onUpdateOrInstall forced rebuild
  • Repro scale: ~6.5k notes in the reported vault
Lingua principale
JavaScript
Stelle
203
Fork
81
Merge medio
52m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NotePlan/plugins

Tutte le issue di NotePlan/plugins

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.