js-stellar-sdk icon indicating copy to clipboard operation
js-stellar-sdk copied to clipboard

Keypair fromSecret causes Segmentation Fault in node alpine

Open bitgoAaron opened this issue 3 years ago • 8 comments

Describe the bug Trying to use stellar-sdk's Keypair fromSecret function does not work in alpine flavors of linux.

What version are you on?

To Reproduce

  • npm init -y && npm i stellar-sdk@latest
  • edit package.json :
   "scripts": {
      "test": "node index.js"
    }
  • Create an index.js file:
const stellar = require('stellar-sdk');
const prv = 'SA22TDBINLZMGYUDVXGUP2JMYIQ3DTJE53PNQUVCDK73XRS6TDVYU7WW';
console.log(stellar.Keypair.fromSecret(prv));
  • docker run -it -v $(pwd):/srv -w /srv node:16-alpine npm run test

Error Output:

npm ERR! path /srv
npm ERR! command failed
npm ERR! signal SIGSEGV
npm ERR! command sh -c -- node index.js

Expected behavior

  • Should work without throwing a SIGSEGV (segmentation fault) when creating a KeyPair

Additional context

  • node16 and node18 (non-alpine) work fine.

bitgoAaron avatar Nov 08 '22 05:11 bitgoAaron

@bitgoAaron I was running into the same issues and managed to get it working on node 16 slim. I also installed build-essential using apt-get. The final image size didn't end up being that much larger.

corymsmith avatar Jan 07 '23 21:01 corymsmith

Spent 3 days trying to understand why my project worked locally but when i deploy to kubernetes cluster it doesn't even start.

Thanks @corymsmith

1baga avatar Jun 01 '23 21:06 1baga

I’m glad you managed to get it sorted because I spent a ton of time starting out what was going on.

On Thu, Jun 1, 2023 at 3:56 PM Umar Mash @.***> wrote:

Spent 3 days trying to understand why my project worked locally but when i deploy to kubernetes cluster it doesn't even start.

Thanks @corymsmith https://github.com/corymsmith

— Reply to this email directly, view it on GitHub https://github.com/stellar/js-stellar-sdk/issues/798#issuecomment-1572840340, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABZE5KRB65OT3MKQL64BTXJEFYDANCNFSM6AAAAAARZ5WSQE . You are receiving this because you were mentioned.Message ID: @.***>

-- Thanks,

Cory

corymsmith avatar Jun 01 '23 22:06 corymsmith

Thanks for bringing this thread out from the depths, guys, and documenting the solution @corymsmith :pray:

I imagine this is because sodium-native fails to compile, which you can (probably) work around by not installing optional dependencies (npm i --omit optional stellar-sdk).

Shaptic avatar Jun 02 '23 18:06 Shaptic