api.runOnBackend error says don't use async
but it's not used
#6488
-
TriliumNext Version0.90.7-beta What operating system are you using?Windows What is your setup?Local (no sync) Operating System Versionwin 11 pro (10.0.22631 N/A Build 22631) DescriptionI'm attempting to get command-palette script working with Trilium Next 0.90.7-beta and am getting this error:
Likely the error is their responsibility however in investigating I don't see how to follow the advice in the error message, so maybe the problem is shared. The code triggering the message appears to be: async function getAvailableNotes(query) {
const noteObjs = await api.runOnBackend(searchNotes, [query]);
return noteObjs;
}
//...snip...
async showCommands(query) {
const commands = await api.runOnBackend(getAvailableCommands, [query.trim()]);
await this.renderItems(commands);
} However xref justyns/trilium-scripts#12 Error logsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'm betraying my javascript ignorance, and readng incomprehension: the functions begin with |
Beta Was this translation helpful? Give feedback.
The way to handle it is described in the error.
Instead of using
runOnBackend
which requires a non-async function, you can userunAsyncOnBackendWithManualTransactionHandling
instead. This differentiation is made because you're not supposed to do any database operations while running asynchronously.