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

Fix problem with bcrypt library linkage breaking in dev #1391

Closed
metasoarous opened this issue Apr 19, 2022 · 6 comments · Fixed by #1400
Closed

Fix problem with bcrypt library linkage breaking in dev #1391

metasoarous opened this issue Apr 19, 2022 · 6 comments · Fixed by #1400
Labels
🐛 bug ⚒️ infrastructure Re: automation, continuous integration. javascript Pull requests that update Javascript code 🔩 p:server

Comments

@metasoarous
Copy link
Member

metasoarous commented Apr 19, 2022

Had trouble getting the system started with docker-compose with the dev overlay because I kept getting an error like Error: Cannot find module .... bcrypt.

This seemed to have been caused by some build directory corruption, and was fixed by the suggestion here of running npm rebuild. Of course, this had to be done from within the polis-server container, so the trick is to get the system running, then run docker ps to find the process id, then use that in the command docker exec -it xxxxxxxx /bin/sh to get a shell, from which npm rebuild can be executed.

Any additional context which might be relevant?

I've had similar problems with primordials in the past which might have been fixed by doing this.

I wish there was a way to get fresh builds every time (for sure), but this might have to do with the image mapping (as a dev convenience), combined with some failure of npm to do the right thing.

@metasoarous metasoarous changed the title Document fix to problem with bcrypt not being found Fix problem with bcrypt library linkage breaking in dev Apr 19, 2022
@metasoarous metasoarous added 🐛 bug ⚒️ infrastructure Re: automation, continuous integration. 🙋🏾‍♀️ help wanted 🔩 p:server javascript Pull requests that update Javascript code and removed docs labels Apr 19, 2022
@metasoarous
Copy link
Member Author

Now seeing this manifest in a slightly different manner with Error: Error loading shared library /app/node_modules/bcrypt/lib/binding/napi-v3/brcypt-lib.node: Exec format error

image

This time, the npm rebuild trick did not work for the user. After a little research, it seemed like adding node_modules to the server/.dockerignore might fix things, but as it turns out, this is already in our dockerignore 🤔

Very unclear why this issue is manifesting this way, but it only seems to occur when trying to run in development mode, so maybe this has to do with the typescript watch somehow.

In any case, clear now that this is an actual bug (if intermittent) that needs to be solved, not just a transient issue due to old build state on my machine (this new error was reported by a new developer just firing up the project).

@sirodoht
Copy link
Contributor

This message might be relevant (from the npm build log):

Pre-built binaries not installable for bcrypt@5.0.1 and node@14.14.0 (node-v83 ABI, musl) (falling back to source compile with node-gyp)

metasoarous added a commit that referenced this issue Apr 19, 2022
* try to switch to bcryptjs

* switch auth.password module to use bcryptjs; fixes #1391
@metasoarous
Copy link
Member Author

@sirodoht Thanks again for helping debug this! I'm sorry we weren't able to get it resolved sooner while the hack night was still ongoing, but I think I figured out why switching to bcryptjs didn't work. There was an additional server file that we needed to update to refer to bcryptjs (also, it took a couple of starts for the change to get picked up). Anyway, this should be resolved now, and I'd greatly appreciate it if you'd give it another whirl when you have time.

Thanks again!

@sirodoht
Copy link
Contributor

Just tried and it works now! I think the problem wasn't the second file after all, but the fact that I didn't rm -rf node_modules. Anyhoo, all good now 👌

@metasoarous
Copy link
Member Author

Excellent! Glad to hear it.

And yes, not cleaning out the node_modules may have been what led me to have to rerun a couple times to get it working.

Nevertheless, on my first pass through it didn't work, and I very nearly missed that the error the second time around was coming not from server.ts, but from auth/password.ts (easy to miss in part because server.ts was still showing up in the trace, since it's what requires `passwords.ts).

Anyway; Glad to have this resolved, whatever the original issue actually was. Thanks again for persisting on this with me!

@Skipper-kenya
Copy link

using bcryptjs instead of bcrypt solved my issue

Now seeing this manifest in a slightly different manner with Error: Error loading shared library /app/node_modules/bcrypt/lib/binding/napi-v3/brcypt-lib.node: Exec format error

image

This time, the npm rebuild trick did not work for the user. After a little research, it seemed like adding node_modules to the server/.dockerignore might fix things, but as it turns out, this is already in our dockerignore 🤔

Very unclear why this issue is manifesting this way, but it only seems to occur when trying to run in development mode, so maybe this has to do with the typescript watch somehow.

In any case, clear now that this is an actual bug (if intermittent) that needs to be solved, not just a transient issue due to old build state on my machine (this new error was reported by a new developer just firing up the project).

using bcryptjs instead of bcrypt solved my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug ⚒️ infrastructure Re: automation, continuous integration. javascript Pull requests that update Javascript code 🔩 p:server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants