Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Bug report) api.runOnBackend error says don't use async but it's not used #490

Open
maphew opened this issue Oct 14, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@maphew
Copy link

maphew commented Oct 14, 2024

TriliumNext Version

0.90.7-beta

What operating system are you using?

Windows

What is your setup?

Local (no sync)

Operating System Version

win 11 pro (10.0.22631 N/A Build 22631)

Description

I'm attempting to get command-palette script working with Trilium Next 0.90.7-beta and am getting this error:

Error: You're passing an async function to api.runOnBackend() which will likely not work as you intended. Either make the function synchronous (by removing 'async' keyword), or use api.runAsyncOnBackendWithManualTransactionHandling()

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 async keyword is not being used, so how can it be removed?


xref justyns/trilium-scripts#12

Error logs

No response

@maphew
Copy link
Author

maphew commented Oct 14, 2024

I'm betraying my javascript ignorance, and readng incomprehension: the functions begin with async! I was looking for a parameter. At any rate, my question remains: what's the proper way to deal with this?

@eliandoran eliandoran added the bug Something isn't working label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants