bun
bun copied to clipboard
new error with 0.4.0, benchmark.js instantiating a suite
What version of Bun is running?
0.4.0 Edit: happens with 0.5.0 now too
What platform is your computer?
Linux 5.15.79.1-microsoft-standard-WSL2 x86_64 unknown
What steps can reproduce the bug?
I found this issue running superjson's included benchmarks, specifically this file benchmark.js - the signficant piece uses Benchmark.js It ran fine under 0.3.0, but after upgrading I get a new error
You could follow their build process (using yarn), but it's easier to roll your own dependencies or hacks to run the script. The issue is triggered on this line when you instantiate a new suite
const suite = new Benchmark.Suite('serialize & deserialize');
What is the expected behavior?
It should just hum along and produce regular output (benchmark data)
What do you see instead?
TypeError: undefined is not a constructor (evaluating 'new Benchmark.Suite("serialize & deserialize")')
Additional information
superjson is kind of inefficient and I'm scratching at a lot of ideas, which is why I was looking at performance.
I did some experiments with ottomated's turbojson, and bun crushes it compared to node. It's a clever project, but I had some problem using it that I couldn't solve quickly, something with how it handles undefined.
Turbojson runs these benchmarks though, so I've compared results using bun/node against super/turbo json. Interesting stuff.
Specifically the issue seems to be with benchmark.js. I peeked for a bit but couldn't figure it out right away what's happening to cause this.
Thanks for filing. This class of error is usually a CommonJS <> ESM interop bug. But not much stuff changed related to that between v0.3.0 and v0.4.0 so this will be interesting to debug
Just following up and being thorough here, no urgency implied: I tested this with new Bun 0.5.0 and it's still present
Following up: I just tested this on bun version 0.6.10 and it seems to work correctly now