From 7567348c54917b2f881d6c68d45f7c15d101954b Mon Sep 17 00:00:00 2001 From: Jessica Janiuk Date: Wed, 31 May 2023 10:09:27 -0400 Subject: [PATCH] Revert "fix(zone.js): enable monkey patching of the `queueMicrotask()` API in node.js (#50467)" (#50529) This reverts commit 381cb982264d30e8c79e77e9186acd6da006e718. PR Close #50529 --- packages/zone.js/karma-build.conf.js | 1 - packages/zone.js/lib/browser/browser.ts | 9 +++++++++ packages/zone.js/lib/browser/rollup-common.ts | 1 - .../zone.js/lib/common/queue-microtask.ts | 19 ------------------- packages/zone.js/lib/node/node.ts | 1 - .../zone.js/lib/zone.configurations.api.ts | 4 ++-- packages/zone.js/test/browser-zone-setup.ts | 1 - .../queue-microtask.spec.ts | 0 packages/zone.js/test/browser_entry_point.ts | 1 + packages/zone.js/test/common_tests.ts | 1 - .../test/node_error_entry_point.init.ts | 1 - 11 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 packages/zone.js/lib/common/queue-microtask.ts rename packages/zone.js/test/{common => browser}/queue-microtask.spec.ts (100%) diff --git a/packages/zone.js/karma-build.conf.js b/packages/zone.js/karma-build.conf.js index 8d754070c7ea7..943a610509fdd 100644 --- a/packages/zone.js/karma-build.conf.js +++ b/packages/zone.js/karma-build.conf.js @@ -13,6 +13,5 @@ module.exports = function(config) { config.files.push('build/test/test_fake_polyfill.js'); config.files.push('build/lib/zone.js'); config.files.push('build/lib/common/promise.js'); - config.files.push('build/lib/common/queue-microtask.js'); config.files.push('build/test/main.js'); }; diff --git a/packages/zone.js/lib/browser/browser.ts b/packages/zone.js/lib/browser/browser.ts index cd0c5150a318e..88521a71f6649 100644 --- a/packages/zone.js/lib/browser/browser.ts +++ b/packages/zone.js/lib/browser/browser.ts @@ -25,6 +25,15 @@ Zone.__load_patch('legacy', (global: any) => { } }); +Zone.__load_patch('queueMicrotask', (global: any, Zone: ZoneType, api: _ZonePrivate) => { + api.patchMethod(global, 'queueMicrotask', delegate => { + return function(self: any, args: any[]) { + Zone.current.scheduleMicroTask('queueMicrotask', args[0]); + } + }); +}); + + Zone.__load_patch('timers', (global: any) => { const set = 'set'; const clear = 'clear'; diff --git a/packages/zone.js/lib/browser/rollup-common.ts b/packages/zone.js/lib/browser/rollup-common.ts index f8b9d48abbccd..7658b7da7c838 100644 --- a/packages/zone.js/lib/browser/rollup-common.ts +++ b/packages/zone.js/lib/browser/rollup-common.ts @@ -10,4 +10,3 @@ import '../zone'; import '../common/promise'; import '../common/to-string'; import './api-util'; -import '../common/queue-microtask'; diff --git a/packages/zone.js/lib/common/queue-microtask.ts b/packages/zone.js/lib/common/queue-microtask.ts deleted file mode 100644 index 253dd8f435f91..0000000000000 --- a/packages/zone.js/lib/common/queue-microtask.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @license - * Copyright Google LLC All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * @fileoverview - * @suppress {missingRequire} - */ - -Zone.__load_patch('queueMicrotask', (global: any, Zone: ZoneType, api: _ZonePrivate) => { - api.patchMethod(global, 'queueMicrotask', delegate => { - return function(self: any, args: any[]) { - Zone.current.scheduleMicroTask('queueMicrotask', args[0]); - } - }); -}); diff --git a/packages/zone.js/lib/node/node.ts b/packages/zone.js/lib/node/node.ts index bf85413e1255f..993138bf38fd3 100644 --- a/packages/zone.js/lib/node/node.ts +++ b/packages/zone.js/lib/node/node.ts @@ -9,7 +9,6 @@ import './node_util'; import './events'; import './fs'; -import '../common/queue-microtask'; import {findEventTasks} from '../common/events'; import {patchTimer} from '../common/timers'; diff --git a/packages/zone.js/lib/zone.configurations.api.ts b/packages/zone.js/lib/zone.configurations.api.ts index 6a602b8cfff57..c45ae9bb2a944 100644 --- a/packages/zone.js/lib/zone.configurations.api.ts +++ b/packages/zone.js/lib/zone.configurations.api.ts @@ -296,9 +296,9 @@ interface ZoneGlobalConfigurations { /** * - * Disable the monkey patching of the `queueMicrotask()` API. + * Disable the monkey patching of the browser's `queueMicrotask()` API. * - * By default, `zone.js` monkey patches the `queueMicrotask()` API + * By default, `zone.js` monkey patches the browser's `queueMicrotask()` API * to ensure that `queueMicrotask()` callback is invoked in the same zone as zone used to invoke * `queueMicrotask()`. And also the callback is running as `microTask` like * `Promise.prototype.then()`. diff --git a/packages/zone.js/test/browser-zone-setup.ts b/packages/zone.js/test/browser-zone-setup.ts index cfff6d9eaf435..264d797b7ac97 100644 --- a/packages/zone.js/test/browser-zone-setup.ts +++ b/packages/zone.js/test/browser-zone-setup.ts @@ -11,7 +11,6 @@ if (typeof window !== 'undefined') { (window as any)[zoneSymbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] = true; } import '../lib/common/to-string'; -import '../lib/common/queue-microtask'; import '../lib/browser/api-util'; import '../lib/browser/browser-legacy'; import '../lib/browser/browser'; diff --git a/packages/zone.js/test/common/queue-microtask.spec.ts b/packages/zone.js/test/browser/queue-microtask.spec.ts similarity index 100% rename from packages/zone.js/test/common/queue-microtask.spec.ts rename to packages/zone.js/test/browser/queue-microtask.spec.ts diff --git a/packages/zone.js/test/browser_entry_point.ts b/packages/zone.js/test/browser_entry_point.ts index 4bd23a30f0f0e..d3cf4518efaf5 100644 --- a/packages/zone.js/test/browser_entry_point.ts +++ b/packages/zone.js/test/browser_entry_point.ts @@ -28,3 +28,4 @@ import './mocha-patch.spec'; import './jasmine-patch.spec'; import './browser/messageport.spec'; import './extra/cordova.spec'; +import './browser/queue-microtask.spec'; diff --git a/packages/zone.js/test/common_tests.ts b/packages/zone.js/test/common_tests.ts index 52c384fe7795c..5539bae4ce6be 100644 --- a/packages/zone.js/test/common_tests.ts +++ b/packages/zone.js/test/common_tests.ts @@ -11,7 +11,6 @@ import './common/zone.spec'; import './common/task.spec'; import './common/util.spec'; import './common/Promise.spec'; -import './common/queue-microtask.spec'; import './common/fetch.spec'; import './common/Error.spec'; import './common/setInterval.spec'; diff --git a/packages/zone.js/test/node_error_entry_point.init.ts b/packages/zone.js/test/node_error_entry_point.init.ts index 1937170d07b26..651ec727c20ff 100644 --- a/packages/zone.js/test/node_error_entry_point.init.ts +++ b/packages/zone.js/test/node_error_entry_point.init.ts @@ -11,7 +11,6 @@ import './test_fake_polyfill'; // Setup tests for Zone without microtask support import '../lib/zone'; import '../lib/common/promise'; -import '../lib/common/queue-microtask'; import '../lib/common/to-string'; import './test-env-setup-jasmine'; import './wtf_mock';