Skip to content

Commit

Permalink
fix(zone.js): path entire promise in node
Browse files Browse the repository at this point in the history
In angular#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 nodejs/node#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 angular#50513, closes angular#50457, closes angular#50414 and closes angular#49930
  • Loading branch information
alan-agius4 committed Jun 2, 2023
1 parent 9847085 commit e6fee68
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 136 deletions.
2 changes: 1 addition & 1 deletion packages/zone.js/bundles.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ BUNDLES_ENTRY_POINTS = {
"entrypoint": _DIR + "mix/rollup-mix",
},
"zone-node": {
"entrypoint": _DIR + "node/rollup-main-node-bundle",
"entrypoint": _DIR + "node/rollup-main",
},
"async-test": {
"entrypoint": _DIR + "testing/async-testing",
Expand Down
117 changes: 0 additions & 117 deletions packages/zone.js/lib/node/promise.ts

This file was deleted.

12 changes: 0 additions & 12 deletions packages/zone.js/lib/node/rollup-main-node-bundle.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/zone.js/lib/node/rollup-test-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/

import './rollup-main-node-bundle';
import './rollup-main';
// load test related files into bundle
import '../testing/zone-testing';
4 changes: 0 additions & 4 deletions packages/zone.js/test/promise/promise-adapter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,4 @@ const rejected = (reason) => {
return Promise.reject(reason);
};

process.on('unhandledRejection', (error) => {
console.log('unhandled', error);
});

export default {deferred, resolved, rejected};
2 changes: 1 addition & 1 deletion packages/zone.js/test/promise/promise-test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import promisesAplusTests from 'promises-aplus-tests';
import adapter from './promise-adapter.mjs';

promisesAplusTests(adapter, {reporter: 'dot', timeout: 500}, function (err) {
promisesAplusTests(adapter, {reporter: 'dot'}, function (err) {
if (err) {
console.error(err);
process.exit(1);
Expand Down

0 comments on commit e6fee68

Please sign in to comment.