GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(zone.js): enable monkey patching of the `queueMicrotask()` API in node.js [Take 2] by alan-agius4 · Pull Request #50530 · angular/angular

fix(zone.js): enable monkey patching of the queueMicrotask() API in node.js [Take 2] #50530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alan-agius4 wants to merge 2 commits into angular:main from alan-agius4:zone-js-api-patch

Uh oh!

There was an error while loading. Please reload this page.

Closed

fix(zone.js): enable monkey patching of the queueMicrotask() API in node.js [Take 2] #50530

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
6b685bb
fix(zone.js): enable monkey patching of the `queueMicrotask()` API in…
alan-agius4 May 25, 2023
23e5b1f
fixup! fix(zone.js): enable monkey patching of the `queueMicrotask()`…
alan-agius4 Jun 1, 2023
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

14 changes: 5 additions & 9 deletions 14 packages/zone.js/lib/browser/browser.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

import {findEventTasks} from '../common/events';
import {patchQueueMicrotask} from '../common/queue-microtask';
import {patchTimer} from '../common/timers';
import {patchClass, patchMethod, patchPrototype, scheduleMacroTaskWithCurrentZone, ZONE_SYMBOL_ADD_EVENT_LISTENER, ZONE_SYMBOL_REMOVE_EVENT_LISTENER, zoneSymbol,} from '../common/utils';

Expand All @@ -25,15 +26,6 @@ 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';
Expand Down Expand Up @@ -300,3 +292,7 @@ Zone.__load_patch('PromiseRejectionEvent', (global: any, Zone: ZoneType) => {
findPromiseRejectionHandler('rejectionhandled');
}
});

Zone.__load_patch('queueMicrotask', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
patchQueueMicrotask(global, api);
});
19 changes: 19 additions & 0 deletions 19 packages/zone.js/lib/common/queue-microtask.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @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}
*/

export function patchQueueMicrotask(global: any, api: _ZonePrivate) {
api.patchMethod(global, 'queueMicrotask', (delegate) => {
return function(self: any, args: any[]) {
Zone.current.scheduleMicroTask('queueMicrotask', args[0]);
};
});
}
5 changes: 5 additions & 0 deletions 5 packages/zone.js/lib/node/node.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import './events';
import './fs';

import {findEventTasks} from '../common/events';
import {patchQueueMicrotask} from '../common/queue-microtask';
import {patchTimer} from '../common/timers';
import {ArraySlice, isMix, patchMacroTask, patchMicroTask} from '../common/utils';

Expand Down Expand Up @@ -152,3 +153,7 @@ Zone.__load_patch('console', (global: any, Zone: ZoneType) => {
}
});
});

Zone.__load_patch('queueMicrotask', (global: any, Zone: ZoneType, api: _ZonePrivate) => {
patchQueueMicrotask(global, api);
});
4 changes: 2 additions & 2 deletions 4 packages/zone.js/lib/zone.configurations.api.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ interface ZoneGlobalConfigurations {

/**
*
* Disable the monkey patching of the browser's `queueMicrotask()` API.
* Disable the monkey patching of the `queueMicrotask()` API.
*
* By default, `zone.js` monkey patches the browser's `queueMicrotask()` API
* By default, `zone.js` monkey patches the `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()`.
Expand Down
1 change: 0 additions & 1 deletion 1 packages/zone.js/test/browser_entry_point.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ import './mocha-patch.spec';
import './jasmine-patch.spec';
import './browser/messageport.spec';
import './extra/cordova.spec';
import './browser/queue-microtask.spec';
0 ...e.js/test/browser/queue-microtask.spec.ts → ...ne.js/test/common/queue-microtask.spec.ts
Show comments
View file
Open in desktop
File renamed without changes.
1 change: 1 addition & 0 deletions 1 packages/zone.js/test/common_tests.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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';
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.