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 — process: do not lazily load AsyncResource · nodejs/node@e9110d5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/process
    • task_queues.js
  • test/parallel
    • test-bootstrap-modules.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/process/task_queues.js‎

Copy file name to clipboardExpand all lines: lib/internal/process/task_queues.js
+8-11Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ const {
3939
} = require('internal/errors').codes;
4040
const FixedQueue = require('internal/fixed_queue');
4141

42+
const { AsyncResource } = require('async_hooks');
43+
4244
// *Must* match Environment::TickInfo::Fields in src/env.h.
4345
const kHasTickScheduled = 0;
4446

@@ -132,16 +134,6 @@ function nextTick(callback) {
132134
queue.push(tickObject);
133135
}
134136

135-
let AsyncResource;
136-
const defaultMicrotaskResourceOpts = { requireManualDestroy: true };
137-
function createMicrotaskResource() {
138-
// Lazy load the async_hooks module
139-
if (AsyncResource === undefined) {
140-
AsyncResource = require('async_hooks').AsyncResource;
141-
}
142-
return new AsyncResource('Microtask', defaultMicrotaskResourceOpts);
143-
}
144-
145137
function runMicrotask() {
146138
this.runInAsyncScope(() => {
147139
const callback = this.callback;
@@ -153,12 +145,17 @@ function runMicrotask() {
153145
});
154146
}
155147

148+
const defaultMicrotaskResourceOpts = { requireManualDestroy: true };
149+
156150
function queueMicrotask(callback) {
157151
if (typeof callback !== 'function') {
158152
throw new ERR_INVALID_ARG_TYPE('callback', 'function', callback);
159153
}
160154

161-
const asyncResource = createMicrotaskResource();
155+
const asyncResource = new AsyncResource(
156+
'Microtask',
157+
defaultMicrotaskResourceOpts
158+
);
162159
asyncResource.callback = callback;
163160

164161
enqueueMicrotask(FunctionPrototypeBind(runMicrotask, asyncResource));
Collapse file

‎test/parallel/test-bootstrap-modules.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-bootstrap-modules.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const expectedModules = new Set([
3131
'Internal Binding types',
3232
'Internal Binding url',
3333
'Internal Binding util',
34+
'NativeModule async_hooks',
3435
'NativeModule buffer',
3536
'NativeModule events',
3637
'NativeModule fs',

0 commit comments

Comments
0 (0)
You are visitor 01402503 — 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.