Jarred Sumner Profile picture
Feb 3 6 tweets 1 min read
setTimeout & setInterval in Bun should return
Currently, it returns a number. Some packages expect .ref() and .unref() to always exist though
Extremely cursed alternative (which we will not do)

Make "ref" and "unref" functions on Number.prototype that masquerade as undefined. When you call call .ref() or .unref() on the result from a timer (or any number), it runs without exception. typeof id.ref would be "undefined"
Slightly less cursed alternative

class Timer extends Number {
ref() {}
unref() {}
}
Another idea, make it extend Promise but coercible to a Number. Native support for `await setTimeout`

class Timer extends Promise {
ref() {}
unref() {}
[Symbol.toPrimitive]() { return this.#id; }
}
to be clear, not going to introduce a new thing here, just going to make it compatible with either node or browsers but would love to figure out a way for it to be both

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Jarred Sumner

Jarred Sumner Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @jarredsumner

Feb 3
Bun v0.5.5:
- "node:http" module can send requests now (client)
- bug fixes for bun install, text encoding, and possible stack overflow in console.log(strong)

bun.sh/blog/bun-v0.5.5
Read 4 tweets
Dec 23, 2022
Introducing Bun v0.4.0

- bunx: auto-install & run npm executables
- bun pm ls: list pkg versions
- bun install bugfixes for package hoisting & empty folders
- bun:test gets jest lifecycle hooks
- node:util/types
- node:stream & process.stdin bugfixes

Read the the release notes for Bun v0.4.0

bun.sh/blog/bun-v0.4.0
Read 7 tweets
Dec 22, 2022
one bugfix away from bun v0.4.0
Hoisting bug in bun install me and @dylanconway111 spent much of today on.

bun install occasionally places the wrong package version in node_modules when multiple versions of the same package are installed. But the minimum case where this happens is difficult to narrow
The easiest package for us to repro this with right now is netlify-cli, but it can’t be the only one where this happens
Read 4 tweets
Aug 2, 2022
Bun as a bundler/transpiler independent of the runtime was de-prioritized so the rest could ship, but it will be re-prioritized in the coming months
Bun today isn’t a serious webpack/Babel/swc/esbuild/terser alternative because it lacks a minifier and it doesn’t optimize for production bundling — this will need to change

One of the goals of the project to fix this will be: on by default in bun’s runtime
A prerequisite of this is sourcemaps — which is implemented today. That’s how bun’s errors produce line numbers to original source code. It eagerly stores a sourcemap of every transpiled file.
Read 7 tweets
Aug 2, 2022
bun v0.1.6 is released!
- Fixes "Illegal instruction" error
- 396x faster TypedArray.from (thx @Constellation)
- 3.5x faster JSON.stringify (thx @darinadler)
- about 2% faster JS execution on Linux due to enabling libpas

github.com/oven-sh/bun/re…
@Constellation @darinadler i forgot to mention

TypedArray.slice() gets around 25% faster too
@Constellation @darinadler sometimes its actually 1.5x and not 25%
Read 4 tweets
Aug 1, 2022
If you get "illegal instruction error" when loading bun, can you tell me if it still happens with these two builds?

macOS: github.com/oven-sh/bun/re…
linux: github.com/oven-sh/bun/re…
I'm fairly confident this does fix it because I am now able to load bun via Rosetta on macOS x64 on that macOS build and Rosetta doesn't support AVX instructions which is the cause of the crash on old CPUs
cc @ZoltanKochan - i remember you tried it and ran into this, can you give this build a try?
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(