Tonight I tried using the Bun JavaScript run time for a simple script to uploading Ghost’s admin’s API.
As advertised, it was easy to get started with Bun. Bun has TypeScript support of the box and includes support for top-level await
.
It also seemed to have no problem with me installing and using the @tryghost/admin-api
just like in Node. So far, so good.
But actually trying to upload something fails with an error:
109 |
110 | if (!secretOrPrivateKey && options.algorithm !== 'none') {
111 | return failure(new Error('secretOrPrivateKey must have a value'));
112 | }
113 |
114 | if (secretOrPrivateKey != null && !(secretOrPrivateKey instanceof KeyObject)) {
^
TypeError: Right hand side of instanceof is not an object
at /home/mark/git/Ghost-new/node_modules/jsonwebtoken/sign.js:114:38
I traced this back to an open bug report about Bun not supporting some Node crypto features, including KeyObject
: Implement `KeyObject` (`node:crypto`) · Issue #2036 · oven-sh/bun · GitHub
That was a blocker, and I gave up with Bun then.
But it wasn’t the only the significant bug I ran into Bun in my short time with it.
Bun also has a bug when fetch()
is used on localhost URLs, although swapping them to 127.0.0.1 works fine:
Alll that is to say: Bun isn’t fully baked yet.