Open Akumzy opened 1 month ago
looked into this and it is specific to bun build
nanoid/index.js
initializes its global variables like so
const POOL_SIZE_MULTIPLIER = 128
let pool, poolOffset
bug.js
however does it like so
var POOL_SIZE_MULTIPLIER = 128,
pool = 128,
poolOffset = 128;
there is later a lazy check if (!pool
to assign pool to a call to Buffer.allocUnsafe
. since thats never true however the code continues and tries calling pool.subarray()
on a number
.
What version of Bun is running?
1.1.28+cf4e9cb69
What platform is your computer?
Darwin 24.0.0 arm64 arm
What steps can reproduce the bug?
Code:
Build:
Run:
What is the expected behavior?
Something like this
What do you see instead?
Additional information
To be honest I can not remember why I was lazy loading the nanoid module but once you move the import outside the function it'll start behaving as expected