node.bcrypt.js icon indicating copy to clipboard operation
node.bcrypt.js copied to clipboard

Bcrypt compare (only this method) crashing node application on Docker.

Open davinpkn opened this issue 5 years ago • 4 comments

Recently I'm using node:alpine on my Dockerfile, after that bcrypt.compare started failing & it's crashing the server.

This went wrong - bcrypt.compare not working with node:alpine This should happen? - Login should have proceeded, my code is alright: const isUserPassword = await bcrypt.compare(password, user.pwdHash) Version of nodejs and OS? Docker with node:alpine as the base image and OS Windows which is irrelevant in case of Docker.

Even doing the build from source or restarting docker service, the error persists :/

I tried to solve it myself, but even inside the try-catch block, the error log is not displayed. Very strange because it's just the 'compare' method, I can generate the hash normally

Here is my dockerfile:


WORKDIR /usr/app

COPY package*.json .sequelizerc ./

RUN apk --no-cache add --virtual builds-deps build-base python

RUN npm install

RUN npm rebuild bcrypt --build-from-source

COPY . .

EXPOSE 3333

CMD ["npm", "run", "dev"]

davinpkn avatar Feb 24 '21 21:02 davinpkn

Are you copying node_modules inside the container from outside? Ideally, you should have the node_modules in the .dockerignore

recrsn avatar Feb 25 '21 02:02 recrsn

I have .dockerignore file with node_modules inside. Isn't it. I tried to change from alpine image to another, and it works, but i need to know what's going on :/

davinpkn avatar Mar 08 '21 02:03 davinpkn

Can you try with the new v5.0.1?

Sometimes there are some ABI incompatibilities between different versions of alpine and it is hard to detect

recrsn avatar Mar 08 '21 17:03 recrsn

I Tried and isn't work, but I left the alpine version and went to node: latest and everything worked normally

davinpkn avatar May 30 '21 16:05 davinpkn