TypeError: Cannot read properties of undefined (reading '_bn')

I trying to debug why I get the above error when running my nodejs express server in railway. The full error:
$ ts-node ./dist/index.js
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
Error: Validation failed!
at createHook (/app/dist/utils/shyft.js:77:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Server.<anonymous> (/app/dist/index.js:242:22)
Validation failed!
/app/node_modules/@solana/web3.js/src/publickey.ts:39
return (value as PublicKeyData)._bn !== undefined;
^
TypeError: Cannot read properties of undefined (reading '_bn')
at isPublicKeyData (/app/node_modules/@solana/web3.js/src/publickey.ts:39:35)
at new PublicKey (/app/node_modules/@solana/web3.js/src/publickey.ts:58:9)
at Server.<anonymous> (/app/dist/index.js:249:124)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ ts-node ./dist/index.js
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
Error: Validation failed!
at createHook (/app/dist/utils/shyft.js:77:19)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Server.<anonymous> (/app/dist/index.js:242:22)
Validation failed!
/app/node_modules/@solana/web3.js/src/publickey.ts:39
return (value as PublicKeyData)._bn !== undefined;
^
TypeError: Cannot read properties of undefined (reading '_bn')
at isPublicKeyData (/app/node_modules/@solana/web3.js/src/publickey.ts:39:35)
at new PublicKey (/app/node_modules/@solana/web3.js/src/publickey.ts:58:9)
at Server.<anonymous> (/app/dist/index.js:249:124)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
It has something to do wih the @solana/web3.js package and some fixes suggested here (https://solana.stackexchange.com/questions/4077/bigint-failed-to-load-bindings-pure-js-will-be-used-try-npm-run-rebuild-whe) did not work. project-id: 060de268-5246-4c9c-b27e-dfaaf4e8fecc Everything is running fine locally.
Solana Stack Exchange
bigint: Failed to load bindings, pure JS will be used (try npm run ...
When attempting to import Connection from @solana/web3.js, this appears when it is run: bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?) It appears to still run, but I am
34 Replies
Percy
Percyβ€’7mo ago
Project ID: 060de268-5246-4c9c-b27e-dfaaf4e8fecc
Brody
Brodyβ€’7mo ago
forgive me for asking, but you have ran npm run rebuild right?
_daniel.sol | NFTs For Less
I have, yes.
(base) ➜ nftsforless-shyft git:(main) railway run npm rebuild
rebuilt dependencies successfully
(base) ➜ nftsforless-shyft git:(main) railway run npm rebuild
rebuilt dependencies successfully
I have also ran yarn cache clean
(base) ➜ nftsforless-shyft git:(main) railway run yarn cache clean
yarn cache v1.22.19
success Cleared cache.
✨ Done in 0.02s.
(base) ➜ nftsforless-shyft git:(main) railway run yarn cache clean
yarn cache v1.22.19
success Cleared cache.
✨ Done in 0.02s.
still no change
Brody
Brodyβ€’7mo ago
you've totally removed node_modules as well?
Brody
Brodyβ€’7mo ago
I noticed that you are using railway run, are you aware that only runs the given command locally?
_daniel.sol | NFTs For Less
no πŸ™‚ I was under the impression that railway run, runs the command in the deployment environment
Brody
Brodyβ€’7mo ago
for this you wouldn't need railway run, just run the commands locally and push the changes
_daniel.sol | NFTs For Less
:rip: there are no changes to my repo if I run any of the mentioned 3 cmds
Brody
Brodyβ€’7mo ago
nope, there's no way to do that, and for this there's no need to do that, check out the --help printout for more information
_daniel.sol | NFTs For Less
so I have nothing to push
Brody
Brodyβ€’7mo ago
make sure you delete all the would be effected files before running those commands
_daniel.sol | NFTs For Less
I'm not sure I understand. I see a lot of "cached" when trying to railway up is there a command to make railway build fresh?
Brody
Brodyβ€’7mo ago
are you building with nixpacks?
Brody
Brodyβ€’7mo ago
can't hurt to try, set a service variable NIXPACKS_NO_CACHE to 1
_daniel.sol | NFTs For Less
I have a feeling I'm not doing it right this is my railway.toml file
_daniel.sol | NFTs For Less
gotcha nope, no change build seem to be fresh
Brody
Brodyβ€’7mo ago
didnt think this was a cache issue, what node version are you using locally, and what node version is railway building your app with
_daniel.sol | NFTs For Less
locally:
(base) ➜ nftsforless-shyft git:(main) βœ— node --version
v18.2.0
(base) ➜ nftsforless-shyft git:(main) βœ— node --version
v18.2.0
_daniel.sol | NFTs For Less
and from what I can tell railway is using 18 also?
No description
Brody
Brodyβ€’7mo ago
im out of ideas, have you tried googling for the error? TypeError: Cannot read properties of undefined (reading '_bn') found this, i dont know your project so i dont know if its applicable though https://stackoverflow.com/questions/70235249/solana-candy-machine-typeerror-cannot-read-properties-of-undefined-reading-b
_daniel.sol | NFTs For Less
yeah, I was reading the exact thing, let me try a thing or 2 thank you for your help πŸ™‚ I was missing an env var ...
Brody
Brodyβ€’7mo ago
makes sense given you might not have known about the service variables
_daniel.sol | NFTs For Less
no, I had all my vars in place, (got confused about the term - "service variables") but with one update, locally I introduced a new env var that I forgot to add in in railway thanks again for help it literraly bugged me for half a day :rip:
Brody
Brodyβ€’7mo ago
they're called service variables because it's a service and those are the services variables
_daniel.sol | NFTs For Less
now I know :respect:
Brody
Brodyβ€’7mo ago
glad its working!
_daniel.sol | NFTs For Less
once again, thank you for taking the time to help me
Brody
Brodyβ€’7mo ago
no problem! πŸ™‚
Nereos
Nereosβ€’6mo ago
hey @_danielpavel, I am having a similar issue, what var exactly you forgot? the no cache one?
_daniel.sol | NFTs For Less
Well, I’m not sure how my particular case helps you. You have to check your code and see which one you’ve missed and used assuming it’s holds a value comming from your env but it’s actually undefined β€˜cuz you have not set it