oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.54k stars 2.71k forks source link

Bun doesn't work with sodium-native #3652

Open vjau opened 1 year ago

vjau commented 1 year ago

What version of Bun is running?

0.6.14

What platform is your computer?

Linux 5.4.0-153-generic x86_64 x86_64 (Ubuntu 20.04)

What steps can reproduce the bug?

sodium-native is a thin wrapper around libsodium I don't know if the bug is crypto or ffi related.

sodium-native is exporting constants that are not bound when imported in bun code. This lib is used by @fastify/secure-session plugin

//index.mjs
import sodium from "sodium-native";

console.log("sodium", sodium.crypto_secretbox_NONCEBYTES);
console.log("sodium", sodium.crypto_secretbox_KEYBYTES);

Output with bun

sodium undefined
sodium undefined

Output with node

sodium 24
sodium 32

What is the expected behavior?

sodium 24 sodium 32

What do you see instead?

sodium undefined sodium undefined

Additional information

No response

vjau commented 1 year ago

Still happening with bun 0.7.0. After some investigation, it's not related to FFI but to n-api.

vjau commented 1 year ago

Still happening with bun 0.7.3

paperdave commented 1 year ago
image

i havent checked but i suspect we dont handle returning an napi_value here, but expecting exports to be mutated.

asoltys commented 10 months ago

Still happening on bun 1.0.14. Just encountered while trying to run an app that relies on @fastify/secure-session

eL1x00r commented 8 months ago

bump here too

tika commented 6 months ago

same here

pentateu commented 5 months ago

+1

bili-jing commented 3 months ago

+1