Commit graph

12 commits

Author SHA1 Message Date
Alan Agius
7837f7119f fix(zone.js): enable monkey patching of the queueMicrotask() API in node.js (#50530)
Similar to the browser, now we also monkey patch `queueMicrotask` in Node.js. This API was added in Node.js 11.

PR Close #50530
2023-06-07 12:42:33 -07:00
Alan Agius
cb31dbc75c fix(zone.js): patch entire promise in node (#50552)
In https://github.com/angular/angular/pull/49144 we introduced a change to only path `Promise.prototype.then` due to Node.js `SafePromise` complaining about `Promise.prototype.then` called on incompatible receiver. This however introduced a number of regressions. This commit reverts this change and re-introduces the changes to patch the entire promise on Node.

The original `SafePromise` problem is no longer reproducible as of Node.js version 18.13+ as it was addressed as part of https://github.com/nodejs/node/pull/45175.

While the Angular CLI does not yet generate ESM server bundles, users using ESM with dynamic imports will require using Node.js 18.13 or later.

Closes #50513, closes #50457, closes #50414 and closes #49930

PR Close #50552
2023-06-02 14:07:18 -07:00
Jessica Janiuk
7567348c54 Revert "fix(zone.js): enable monkey patching of the queueMicrotask() API in node.js (#50467)" (#50529)
This reverts commit 381cb98226.

PR Close #50529
2023-05-31 09:57:42 -07:00
Alan Agius
381cb98226 fix(zone.js): enable monkey patching of the queueMicrotask() API in node.js (#50467)
Similar to the browser, now we also monkey patch `queueMicrotask` in Node.js. This API was added in Node.js 11.

PR Close #50467
2023-05-30 12:57:45 -07:00
JiaLiPassion
d1ac3aa14e fix(zone.js): zone-node only patch Promise.prototype.then (#49144)
Close #47872

zone-node only patches `Promise.prototype.then` instead of patch
`Promise` itself. So the new NodeJS `SafePromise` will not complain
the Promise.prototype.then called on incompatible receiver.

We should also do this change on browser zone.js patch, but it will
be a big breaking change, because Promise.prototype.then will not work
with `fakeAsync` any longer.

PR Close #49144
2023-02-27 08:02:43 -08:00
JiaLiPassion
008eaf3b7d fix(zone.js): should continue to executue listeners when throw error (#41562)
Close #41522

`zone.js` patches event listeners and run all event listeners together, if
one event handler throws error, the listeners afterward may not be invoked.

Reproduction:

```
export class AppComponent implements AfterViewInit {
  @ViewChild('btn') btn: ElementRef;
  title = 'event-error';

  constructor(private ngZone: NgZone) {}

  ngAfterViewInit() {
    this.ngZone.runOutsideAngular(() => {
      this.btn.nativeElement.addEventListener('click', () => {
        throw new Error('test1');
      });
      this.btn.nativeElement.addEventListener('click', () => {
        console.log('add eventlistener click');
      });
    });
  }
}
```

Until now no Angular users report this issue becuase in the `ngZone`, all
error will be caught and will not rethrow, so the event listeners afterward
will still continue to execute, but if the event handlers are outside of `ngZone`,
the error will break the execution.

This commit catch all errors, and after all event listeners finished invocation,
rethrow the errors in seperate `microTasks`, the reason I am using `microTask` here
is to handle multiple errors case.

PR Close #41562
2021-04-21 15:54:08 -07:00
Andrew Kushnir
d58747de8a Revert "fix(zone.js): should continue to executue listeners when throw error (#41562)" (#41707)
This reverts commit 5c48cd30b5.

Reason: that change introduces race conditions on CI.

PR Close #41707
2021-04-19 13:33:10 -07:00
JiaLiPassion
5c48cd30b5 fix(zone.js): should continue to executue listeners when throw error (#41562)
Close #41522

`zone.js` patches event listeners and run all event listeners together, if
one event handler throws error, the listeners afterward may not be invoked.

Reproduction:

```
export class AppComponent implements AfterViewInit {
  @ViewChild('btn') btn: ElementRef;
  title = 'event-error';

  constructor(private ngZone: NgZone) {}

  ngAfterViewInit() {
    this.ngZone.runOutsideAngular(() => {
      this.btn.nativeElement.addEventListener('click', () => {
        throw new Error('test1');
      });
      this.btn.nativeElement.addEventListener('click', () => {
        console.log('add eventlistener click');
      });
    });
  }
}
```

Until now no Angular users report this issue becuase in the `ngZone`, all
error will be caught and will not rethrow, so the event listeners afterward
will still continue to execute, but if the event handlers are outside of `ngZone`,
the error will break the execution.

This commit catch all errors, and after all event listeners finished invocation,
rethrow the errors in seperate `microTasks`, the reason I am using `microTask` here
is to handle multiple errors case.

PR Close #41562
2021-04-19 08:38:42 -07:00
JiaLiPassion
1822cbcd46 fix(zone.js): patch nodejs EventEmtter.prototype.off (#37863)
Close #35473

zone.js nodejs patch should also patch `EventEmitter.prototype.off` as `removeListener`.
So `off` can correctly remove the listeners added by `EventEmitter.prototype.addListener`

PR Close #37863
2020-07-24 15:45:00 -07:00
Joey Perrott
d1ea1f4c7f build: update license headers to reference Google LLC (#37205)
Update the license headers throughout the repository to reference Google LLC
rather than Google Inc, for the required license headers.

PR Close #37205
2020-05-26 14:26:58 -04:00
Danny Skoog
6ab5f3648a refactor: utilize type narrowing (#33075)
PR Close #33075
2019-10-10 15:18:44 -07:00
JiaLiPassion
5eb7426216 build: move zone.js to angular repo (#30962)
PR Close #30962
2019-06-20 11:27:39 -07:00