Today's Trends
mediumInvestigatingBunv1.4.4

Bun Transpiler Incorrectly Rewrites `return undefined` in Async Generators

  1. Investigating(current)
  2. Trending(upcoming)
  3. Workaround available(upcoming)
  4. Resolved(upcoming)

Executive summary

In Bun 1.4.4, the transpiler simplifies `return undefined;` and `return void 0;` to `return;` inside async generator bodies, skipping the required microtask tick. This affects `bun run`, `Bun.Transpiler`, and `bun build`, altering promise resolution order.

No verified workaround yet

None of the linked reports describe a mitigation. Follow this incident to hear when one appears.

Official fix
Technical root cause

The transpiler simplifies return undefined; and return void 0; to return; inside async function* bodies, dropping the microtask tick required when awaiting a returned expression.

Evidence

1 report · 1 GitHubShow
  1. [1]
    GitHub First report
    Transpiler rewrites `return undefined` to `return;` in async generators, skipping the required `Await`(opens GitHub issue in a new tab)

    In Bun 1.4.4 (1.4.4+38afee6c8), the transpiler simplifies return undefined; and return void 0; to return; inside async function* bodies, dropping the microtask tick required when awaiting a returned expression. Because the runtime transpiles modules before execution, this changes promise resolution order in bun run as well as Bun.Transpiler and bun build. const log = []; async function* explicit() { return undefined; } async function* implicit() { return; } explicit().next().then(() =>…

    by trackoor 0upvotes 0comments

Timeline

  1. First report on GitHub issue

    Transpiler rewrites `return undefined` to `return;` in async generators, skipping the required `Await`

    Source