Skip to content

AsyncGenerator should not yield the result of awaited promises in finally block if return is called on it #67053

@ThomasHardwickRocket

Description

@ThomasHardwickRocket

Which @angular/* package(s) are the source of the bug?

zone.js

Is this a regression?

No

Description

I'm trying to use code that uses AsyncGenerator functions with angular.
In particular I want to be able to use .return() in order to interrupt the execution and move to a finally block where we need to do some cleanup.
That cleanup involves a request and so needed to be awaited. I was seeing the result of the request come though unexpectedly.
I then was able to produce the cutdown above.

The same code with zoneless works, along with
in typescript playground or copy pasted into the browser console (with the type annotations removed) produces the correct result.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-aafwbmgx?file=src%2Fmain.ts

Please provide the exception or error you saw

Open the browser console. The output is incorrect.

Please provide the environment you discovered this bug in (run ng version)

npx ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 21.0.6
Angular           : 21.0.7
Node.js           : 24.11.1
Package Manager   : npm 11.6.2
Operating System  : win32 x64

┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package                           │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations               │ 21.0.7            │ 21.0.7            │
│ @angular/build                    │ 21.0.6            │ 21.0.6            │
│ @angular/cdk                      │ 21.0.6            │ 21.0.6            │
│ @angular/cli                      │ 21.0.6            │ 21.0.6            │
│ @angular/common                   │ 21.0.7            │ 21.0.7            │
│ @angular/compiler                 │ 21.0.7            │ 21.0.7            │
│ @angular/compiler-cli             │ 21.0.7            │ 21.0.7            │
│ @angular/core                     │ 21.0.7            │ 21.0.7            │
│ @angular/forms                    │ 21.0.7            │ 21.0.7            │
│ @angular/platform-browser         │ 21.0.7            │ 21.0.7            │
│ @angular/platform-browser-dynamic │ 21.0.7            │ 21.0.7            │
│ @angular/router                   │ 21.0.7            │ 21.0.7            │
│ rxjs                              │ 7.8.2             │ ^7.8.2            │
│ typescript                        │ 5.9.3             │ 5.9.3             │
│ webpack                           │ 5.104.1           │ ^5.104.1          │
│ zone.js                           │ 0.16.0            │ ^0.16.0           │
└───────────────────────────────────┴───────────────────┴───────────────────┘

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions