Sequencing of view plugin updates versus meta data cache update

unrelated: I am in a ViewPlugin (i.e. implements PluginValue) and being called for an update(update: ViewUpdate)

At this point, the document has just been changed via a modification I sent via View.dispatch.

The state in the update correctly shows the new state of the file contents.

However, if I fetch state.field(editorInfoField).file (the current file) and fetch the associated cached metadata via metadataCache.getFileCache(TFile) then I get meta data from BEFORE the change was applied. Specifically, the tags are still as they were before the change to the document.

Is this because

  1. meta data cache updates are async somewhere and I am just early?
  2. the meta data cache gets updated AFTER view plugins are called?
  3. the meta data cache entry is actually updated already, I just have to get it from somewhere else?

update: just decided to measure it. Looks like meta data update is in response to being saved (very async), which is way later. At least that’s what I’d guess from this trace:

onMetadataChanged (MyCodeWatchingEvents.ts:66)
(anonymous) (MyCodeWatchingEvents.ts:16)
e.tryTrigger (app.js:1)
e.trigger (app.js:1)
t.trigger (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
(anonymous) (app.js:1)
Promise.then (async)
e.queue (app.js:1)
t.onCreateOrModify (app.js:1)
e.tryTrigger (app.js:1)
e.trigger (app.js:1)
t.trigger (app.js:1)
t.onChange (app.js:1)
e.trigger (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
e.reconcileFileCreation (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
e.reconcileFileInternal (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
e.reconcileFile (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
e.reconcileInternalFile (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
(anonymous) (app.js:1)
n (app.js:1)
Promise.then (async)
e.queue (app.js:1)
e.write (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
t.modify (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
(anonymous) (app.js:1)
a (app.js:1)
Promise.then (async)
l (app.js:1)
(anonymous) (app.js:1)
g (app.js:1)
t.save (app.js:1)
s (app.js:1)
l (app.js:1)
setTimeout (async)
c (app.js:1)
n.requestSave (app.js:1)
t.onUpdate (app.js:1)
(anonymous) (app.js:1)
e.update (app.js:1)
_dispatch (app.js:1)
e.dispatch (app.js:1)
replaceTag (WidgetBase.ts:17)
eval (RadioGroupWidget.ts:28)
await in eval (async)
s (enhance.js:1)

I will just have to stop using metadata and parse the tags myself I think :frowning: