Repository: angular
Issue: Promise rejection with finally, does not throw unhandled rejection
Labels: area: zones,state: has PR,P4

### Which @angular/* package(s) are the source of the bug?

zone.js

### Is this a regression?

No

### Description

Promise rejection with finally, does not throw unhandled rejection

### Please provide a link to a minimal reproduction of the bug

https://github.com/sviat9440/zone-js-bug-reproduction.git

### Please provide the exception or error you saw

## Expected

1. If the promise is rejected, the final callback should be executed
2. After that, it should throw the UnhandledPromiseRejection error

## Actual without zone.js

```true
Promise.reject(new Error('test error')).finally(() => console.log('finally'));
```

Output:

```
finally
file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/work-as-expected.js:1
Promise.reject(new Error('test error')).finally(() => console.log('finally'));
               ^

Error: test error
    at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/work-as-expected.js:1:16
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Process finished with exit code 1
```

Browser output:
![image](https://user-images.githubusercontent.com/13107421/192618459-5fe9c2d3-b76d-4ebe-bd7e-e8455ac4af4d.png)


Work as expected

## Actual with zone.js

### Case 1

```
import 'zone.js';

Promise.reject(new Error('test error')).finally(() => console.log('finally'));
```

Output:

```
finally

Process finished with exit code 0
```

Browser output:
![image](https://user-images.githubusercontent.com/13107421/192618332-63a82e7b-0965-47f8-a32e-2d1a6a57d5c4.png)

### Case 2

```
import 'zone.js';

Promise.reject(new Error('test error'));
```

Output:

```
Unhandled Promise rejection: test error ; Zone: <root> ; Task: null ; Value: Error: test error
    at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/not-work-as-expected.js:3:16
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12) Error: test error
    at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/not-work-as-expected.js:3:16
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Process finished with exit code 0
```

Browser output:
![image](https://user-images.githubusercontent.com/13107421/192618269-ae0bad68-611e-477a-b438-fcf25eff7b56.png)


UnhandledPromiseRejection error is thrown only without finally callback, exit code was 0


## Workaround

```
import 'zone.js';

try {
  await Promise.reject(new Error('test error'));
} finally {
  console.log('finally');
}
```

Output:

```
Unhandled Promise rejection: test error ; Zone: <root> ; Task: null ; Value: Error: test error
    at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12) Error: test error
    at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)
finally
node:internal/process/esm_loader:94
    internalBinding('errors').triggerUncaughtException(
                              ^

Error: test error
    at file:///C:/Users/User/IdeaProjects/aap/zone-js-bug-reproduction/workaround.js:4:24
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)

Process finished with exit code 1
```

Browser output: 
![image](https://user-images.githubusercontent.com/13107421/192618157-5c794d10-0f77-445d-bcd8-59a6732b4129.png)

Error reported twice: UnhandledPromiseRejection and Error('test error'). Expected no UnhandledPromiseRejection from Zone

## Side effect

Unhandled errors in promises with finally callback is missing. Console is empty. Logging systems also do not see such errors.

In browser the same situation.


### Please provide the environment you discovered this bug in (run `ng version`)

```true
"zone.js": "^0.11.8"
```


### Anything else?

_No response_