Plugin.onloadshould return a
TFolderinstance when provided with a valid existing path
- it returns
Multiple other users have documented issues related to this:
This behavior is not documented at any of these relevant locations:
The user-proposed workaround of using
onLayoutReady does not fully resolve potential use cases of
getAbstractFileByPath. For example, a
MarkdownPostProcessor which requires a
Grammar.wasm asset to be resolved during
Plugin.onload. Moving the registration of the
onLayoutReady results in unprocessed documents when opening an Obsidian workspace with target files already loaded.
Additionally, this seems outside of the scope of
onLayoutReady in terms of expectations based on the naming convention and present documentation. One could reasonably expect that either: [A] (preferably) the
getAbstractFileByPath should provide up-to-date access of the file system during
Plugin.onload, or [B] there should be a documented general
onReady hook or a more specific
Based on a few user comments [1, 2] it seems like the Vault API is dependent on a cache which has not been fully initialized when
onload is executed. As such, it might not be the best approach for cases like the asset-based post-processor I described above, and developers might be better off using the Adapter API in such scenarios. If that is the case, the documentation should be updated to provide more clarity and information about these usage scenarios.
getAbstractFileByPath is used before the cache has been initialized, it would be incredibly helpful if it threw an error or at least logged a warning. The behavior of returning
null silently has caused myself and others a significant amount of unnecessary debugging time, as evidenced by personal experience and the number of related issues I provided. The current documentation does not establish an expectation that it will work in some cases and not others.