Skip to content

chore: port upstream generator fix (FIR-17479)#5

Merged
lorenzhs merged 1 commit intomainfrom
lorenz/port-generator-fix
Dec 4, 2025
Merged

chore: port upstream generator fix (FIR-17479)#5
lorenzhs merged 1 commit intomainfrom
lorenz/port-generator-fix

Conversation

@lorenzhs
Copy link

@lorenzhs lorenzhs commented Dec 4, 2025

Port of facebook@f4f3175

We are using generators more and more -- seems prudent to port upstream fixes.

Summary:
Exceptions from a nested generator are to be re-thrown by yield_value(Generator&)::awaitable::await_resume.

Unfortunately, yield_value(Generator&) has a micro-optimization to avoid suspending when the child generator is ready upon beginning (empty or error). The optimization failed to check for exceptions:

  • on exception is_completed() is true
  • so we would fall through to awaitable{nullptr}
  • which makes no provisions for re-throwing, so the behavior was as if the child generator was empty

Reviewed By: dmm-fb

Differential Revision: D50708988

fbshipit-source-id: 7213b4e28d210c28aa19e4d850481af416e30279

Summary:
Exceptions from a nested generator are to be re-thrown by `yield_value(Generator&)::awaitable::await_resume`.

Unfortunately, `yield_value(Generator&)` has a micro-optimization to avoid suspending when the child generator is ready upon beginning (empty or error). The optimization failed to check for exceptions:
 - on exception `is_completed()` is true
 - so we would fall through to `awaitable{nullptr}`
 - which makes no provisions for re-throwing, so the behavior was as if the child generator was empty

Reviewed By: dmm-fb

Differential Revision: D50708988

fbshipit-source-id: 7213b4e28d210c28aa19e4d850481af416e30279
@lorenzhs lorenzhs merged commit 277c928 into main Dec 4, 2025
1 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants