Unable to use asynchronous wix-data Hooks

Dear wix devs,

I’m running into a blocking problem for me. I’m trying to add a data hook. If my data.js file looks like this:

export function collection_afterUpdate(item) {
  return item;
}

No problem. Hooks can be added to the collection database. But if I do this:

export async function collection_afterUpdate(item) {
  return item;
}

Problem! When I try to add this hook to the collection database, it tells me: “Code error in Hooks file”. It doesn’t tell me what the error is, and it looks like correct JS to me. Also, the documentation and this forum thread tells me async should work (https://www.wix.com/code/home/forum/questions-answers/unique-db-fields).

In the meantime, I’ve found a work-around using Promises without async, but I like async so can anyone tell me what is going wrong? :slight_smile:

Regards,

Henk

One other thing: is it possible to see the debug logs from code in the hooks?

My current solution: in debug mode, actually include any information as a String field in the item…

EDIT: Ok, rejections get displayed in the Content manager. That’s something already :slight_smile:

I had another problem today where a trailing comma in some function parameter also gave the Code Error warning. Since this is also valid JS and I don’t get an error message, this took about an hour to find.

I’m pretty sure that on your side there would be a stack trace or message or something, it would be very helpful if that one is shown along with the Code Error popup.