You have a race condition between your (non-async
) after hook and your async
before hook. You may be able to fix this by making the after hook async
as well. I don’t use collection hooks, so haven’t investigated this behaviour.
I would like to create _id
with auto-increment/nextSeq
.
(by above example I create nextSeq function
and call it in before collection hook
)
Please advise for other solution!
Hey @robfallows, have you noticed that when you nest async functions potential errors get swallowed when only the outermost one is wrapped in try/catch
? That is a caveat when compared to the .then.catch
syntax don’t you think?
I think it’s just something to be aware of. It’s just JavaScript silently swallowing errors, as it will do with evaluating any Promise if you don’t include a .catch
. Syntactically, I think async/await
makes for code that’s easier to read, even if you have to pass exceptions back up - something that I’ve rarely needed to do.