I'm getting a very weird and difficult to reproduce bug...
The process exits with this:
libc++abi: terminating with uncaught exception of type Napi::Error
It happens when I forgot await the compare() promise, e.g.:
async function assertPasswordMatches(plaintextPassword: string, hash: string) {
const matches = /* oops forgot await */ bcrypt.compare(plaintextPassword, hash);
if (!matches) {
throw new AuthError();
}
}
The bug happens when I running a test using vitest. I tried to reproduce in the node.bcrypt.js test files but didn't manage to. :/
bcrypt 5.1.0
node v18.8.0
MacOS M1