Repository navigation
Conversation
Hermes profiles have lowered generators (with `enableBabelRuntime: false`), `for...of`, `?.`, `??` and optional catch binding in dev builds only since #52651, because Hermes couldn't show local variables when paused on a breakpoint in a native generator. That was a Hermes bug: the generator's resume prologue was stamped with the source location of its last `yield`, so a breakpoint on that line resolved to scope-less entry code. It's fixed in facebook/hermes@d1238c8c6 (hermes-v260318099.0.2), which main has used since #58397. This removes `enableRegenerator`, so Hermes-profile dev output matches release. It also fixes a dev/release divergence - loose `for-of` never calls `iterator.return()`, so breaking out of a `for...of` over a generator skipped its `finally` in dev only. Changelog: [General][Changed] - Babel preset: Hermes profiles no longer lower generators, `for...of`, optional chaining, nullish coalescing or optional catch binding in dev, matching release
Collaborator
Author
|
Jest failures are legitimate due to changing some inlining behaviour - looking into that now. I might need to stack a fix under this to do it cleanly. Converting to draft for the moment. |
robhogan
marked this pull request as draft
October 21, 2026 14:31
Collaborator
Author
|
Prerequisite: #59307 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Summary
Since #52651, Hermes profiles have lowered generators (with
enableBabelRuntime: false),for...of,?.,??and optional catch binding in dev builds only, because Hermes couldn't show local variables when paused on a breakpoint in a native generator.That turned out to be a Hermes bug: a breakpoint on that a
yieldline resolved to scope-less entry code before the body had even run. It was fixed in facebook/hermes@d1238c8 (hermes-v260318099.0.2), which main has used since #58397.This removes
enableRegenerator, so Hermes-profile dev output matches release. It also fixes a dev-only divergence - loosefor-ofnever callsiterator.return(), so breaking out of afor...ofover a generator skipped itsfinallyin dev but not release.Note that with the default
enableBabelRuntime, generators were already native in dev, so in practice the generator change mostly affectsenableBabelRuntime: falsesetups, including RN's own Jest. (There's no good reason generator was ever conditional onenableBabelRuntime === false- it seems to date from #44668 and probably a misunderstanding of what theregeneratorargument to@babel/plugin-transform-runtimedid - it doesn't make that plugin transform generators, it just rewrites the helper import.)Native generator debugging still isn't perfect on .0.2 - stepping through
try/catchcan stop on acatchline that doesn't run, and breakpoints onyield*lines or on athrowafter a resume don't fire. Those already affect every default config though, so there's no regression in most cases. Regenerator has its own problems, eg breakpoints often stop a line early because statements merge into itscaseblocks. Overall, native is now a better experience.Detailed comparison in https://robhogan.github.io/reports/react-native-regenerator-removal/
Changelog
[GENERAL] [FIXED] - Babel preset: Hermes profiles no longer lower generators,
for...of, optional chaining, nullish coalescing or optional catch binding in dev, matching releaseTest Plan
Reproduced the original bug through Hermes's
CDPAgenttest harness withDebugger.setBreakpointByUrl. On hermes-v250829098.0.16 and v260318099.0.1, a breakpoint on a generator's lastyieldline pauses at the generator call with only the global scope, and every local evaluates toundefined. On v260318099.0.2 and .0.4 it pauses at the real code with all locals.AI-driven breakpoint sweep: this preset with
dev: true, enableBabelRuntime: false, before and after this change, over 248 source lines of generator, async function, async generator, exception and loop fixtures. A breakpoint was set on every line, each pause was mapped back through the source map, and every local was evaluated. Same results with eager and lazy compilation.