Bun Transpiler Incorrectly Rewrites `return undefined` in Async Generators
- Investigating(current)
- Trending(upcoming)
- Workaround available(upcoming)
- 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 fixThe 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]GitHub First reportTranspiler 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
- First report on GitHub issue
Transpiler rewrites `return undefined` to `return;` in async generators, skipping the required `Await`
Source