| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 49cfb9d commit e95af74
25 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1117,6 +1117,58 @@ Emitted when server receives a request. | |||
| 1117 | 1117 | ||
| 1118 | 1118 | Emitted when server sends a response. | |
| 1119 | 1119 | ||
| 1120 | + #### Modules | ||
| 1121 | + | ||
| 1122 | + `module.require.start` | ||
| 1123 | + | ||
| 1124 | + * `event` {Object} containing the following properties | ||
| 1125 | + * `id` - Argument passed to `require()`. Module name. | ||
| 1126 | + * `parentFilename` - Name of the module that attempted to require(id). | ||
| 1127 | + | ||
| 1128 | + Emitted when `require()` is executed. See [`start` event][]. | ||
| 1129 | + | ||
| 1130 | + `module.require.end` | ||
| 1131 | + | ||
| 1132 | + * `event` {Object} containing the following properties | ||
| 1133 | + * `id` - Argument passed to `require()`. Module name. | ||
| 1134 | + * `parentFilename` - Name of the module that attempted to require(id). | ||
| 1135 | + | ||
| 1136 | + Emitted when a `require()` call returns. See [`end` event][]. | ||
| 1137 | + | ||
| 1138 | + `module.require.error` | ||
| 1139 | + | ||
| 1140 | + * `event` {Object} containing the following properties | ||
| 1141 | + * `id` - Argument passed to `require()`. Module name. | ||
| 1142 | + * `parentFilename` - Name of the module that attempted to require(id). | ||
| 1143 | + * `error` {Error} | ||
| 1144 | + | ||
| 1145 | + Emitted when a `require()` throws an error. See [`error` event][]. | ||
| 1146 | + | ||
| 1147 | + `module.import.asyncStart` | ||
| 1148 | + | ||
| 1149 | + * `event` {Object} containing the following properties | ||
| 1150 | + * `id` - Argument passed to `import()`. Module name. | ||
| 1151 | + * `parentURL` - URL object of the module that attempted to import(id). | ||
| 1152 | + | ||
| 1153 | + Emitted when `import()` is invoked. See [`asyncStart` event][]. | ||
| 1154 | + | ||
| 1155 | + `module.import.asyncEnd` | ||
| 1156 | + | ||
| 1157 | + * `event` {Object} containing the following properties | ||
| 1158 | + * `id` - Argument passed to `import()`. Module name. | ||
| 1159 | + * `parentURL` - URL object of the module that attempted to import(id). | ||
| 1160 | + | ||
| 1161 | + Emitted when `import()` has completed. See [`asyncEnd` event][]. | ||
| 1162 | + | ||
| 1163 | + `module.import.error` | ||
| 1164 | + | ||
| 1165 | + * `event` {Object} containing the following properties | ||
| 1166 | + * `id` - Argument passed to `import()`. Module name. | ||
| 1167 | + * `parentURL` - URL object of the module that attempted to import(id). | ||
| 1168 | + * `error` {Error} | ||
| 1169 | + | ||
| 1170 | + Emitted when a `import()` throws an error. See [`error` event][]. | ||
| 1171 | + | ||
| 1120 | 1172 | #### NET | |
| 1121 | 1173 | ||
| 1122 | 1174 | `net.client.socket` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,7 +269,8 @@ function tracingChannelFrom(nameOrChannels, name) { | |||
| 269 | 269 | ||
| 270 | 270 | class TracingChannel { | |
| 271 | 271 | constructor(nameOrChannels) { | |
| 272 | - for (const eventName of traceEvents) { | ||
| 272 | + for (let i = 0; i < traceEvents.length; ++i) { | ||
| 273 | + const eventName = traceEvents[i]; | ||
| 273 | 274 | ObjectDefineProperty(this, eventName, { | |
| 274 | 275 | __proto__: null, | |
| 275 | 276 | value: tracingChannelFrom(nameOrChannels, eventName), | |
@@ -278,15 +279,16 @@ class TracingChannel { | |||
| 278 | 279 | } | |
| 279 | 280 | ||
| 280 | 281 | get hasSubscribers() { | |
| 281 | - return this.start.hasSubscribers || | ||
| 282 | - this.end.hasSubscribers || | ||
| 283 | - this.asyncStart.hasSubscribers || | ||
| 284 | - this.asyncEnd.hasSubscribers || | ||
| 285 | - this.error.hasSubscribers; | ||
| 282 | + return this.start?.hasSubscribers || | ||
| 283 | + this.end?.hasSubscribers || | ||
| 284 | + this.asyncStart?.hasSubscribers || | ||
| 285 | + this.asyncEnd?.hasSubscribers || | ||
| 286 | + this.error?.hasSubscribers; | ||
| 286 | 287 | } | |
| 287 | 288 | ||
| 288 | 289 | subscribe(handlers) { | |
| 289 | - for (const name of traceEvents) { | ||
| 290 | + for (let i = 0; i < traceEvents.length; ++i) { | ||
| 291 | + const name = traceEvents[i]; | ||
| 290 | 292 | if (!handlers[name]) continue; | |
| 291 | 293 | ||
| 292 | 294 | this[name]?.subscribe(handlers[name]); | |
@@ -296,7 +298,8 @@ class TracingChannel { | |||
| 296 | 298 | unsubscribe(handlers) { | |
| 297 | 299 | let done = true; | |
| 298 | 300 | ||
| 299 | - for (const name of traceEvents) { | ||
| 301 | + for (let i = 0; i < traceEvents.length; ++i) { | ||
| 302 | + const name = traceEvents[i]; | ||
| 300 | 303 | if (!handlers[name]) continue; | |
| 301 | 304 | ||
| 302 | 305 | if (!this[name]?.unsubscribe(handlers[name])) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -189,6 +189,9 @@ let { startTimer, endTimer } = debugWithTimer('module_timer', (start, end) => { | |||
| 189 | 189 | endTimer = end; | |
| 190 | 190 | }); | |
| 191 | 191 | ||
| 192 | + const { tracingChannel } = require('diagnostics_channel'); | ||
| 193 | + const onRequire = getLazy(() => tracingChannel('module.require')); | ||
| 194 | + | ||
| 192 | 195 | const isWindows = process.platform === 'win32'; | |
| 193 | 196 | ||
| 194 | 197 | const relativeResolveCache = { __proto__: null }; | |
@@ -209,7 +212,11 @@ function wrapModuleLoad(request, parent, isMain) { | |||
| 209 | 212 | startTimer(logLabel, traceLabel); | |
| 210 | 213 | ||
| 211 | 214 | try { | |
| 212 | - return Module._load(request, parent, isMain); | ||
| 215 | + return onRequire().traceSync(Module._load, { | ||
| 216 | + __proto__: null, | ||
| 217 | + parentFilename: parent?.filename, | ||
| 218 | + id: request, | ||
| 219 | + }, Module, request, parent, isMain); | ||
| 213 | 220 | } finally { | |
| 214 | 221 | endTimer(logLabel, traceLabel); | |
| 215 | 222 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,9 @@ const { | |||
| 42 | 42 | } = require('internal/modules/helpers'); | |
| 43 | 43 | let defaultResolve, defaultLoad, defaultLoadSync, importMetaInitializer; | |
| 44 | 44 | ||
| 45 | + const { tracingChannel } = require('diagnostics_channel'); | ||
| 46 | + const onImport = tracingChannel('module.import'); | ||
| 47 | + | ||
| 45 | 48 | /** | |
| 46 | 49 | * @typedef {import('url').URL} URL | |
| 47 | 50 | */ | |
@@ -210,10 +213,17 @@ class ModuleLoader { | |||
| 210 | 213 | return compileSourceTextModule(url, source, this); | |
| 211 | 214 | }; | |
| 212 | 215 | const { ModuleJob } = require('internal/modules/esm/module_job'); | |
| 213 | - const job = new ModuleJob( | ||
| 214 | - this, url, undefined, evalInstance, false, false); | ||
| 215 | - this.loadCache.set(url, undefined, job); | ||
| 216 | - const { module } = await job.run(isEntryPoint); | ||
| 216 | + const module = await onImport.tracePromise(async () => { | ||
| 217 | + const job = new ModuleJob( | ||
| 218 | + this, url, undefined, evalInstance, false, false); | ||
| 219 | + this.loadCache.set(url, undefined, job); | ||
| 220 | + const { module } = await job.run(isEntryPoint); | ||
| 221 | + return module; | ||
| 222 | + }, { | ||
| 223 | + __proto__: null, | ||
| 224 | + parentURL: '<eval>', | ||
| 225 | + url, | ||
| 226 | + }); | ||
| 217 | 227 | ||
| 218 | 228 | return { | |
| 219 | 229 | __proto__: null, | |
@@ -470,9 +480,15 @@ class ModuleLoader { | |||
| 470 | 480 | * @returns {Promise<ModuleExports>} | |
| 471 | 481 | */ | |
| 472 | 482 | async import(specifier, parentURL, importAttributes, isEntryPoint = false) { | |
| 473 | - const moduleJob = await this.getModuleJob(specifier, parentURL, importAttributes); | ||
| 474 | - const { module } = await moduleJob.run(isEntryPoint); | ||
| 475 | - return module.getNamespace(); | ||
| 483 | + return onImport.tracePromise(async () => { | ||
| 484 | + const moduleJob = await this.getModuleJob(specifier, parentURL, importAttributes); | ||
| 485 | + const { module } = await moduleJob.run(isEntryPoint); | ||
| 486 | + return module.getNamespace(); | ||
| 487 | + }, { | ||
| 488 | + __proto__: null, | ||
| 489 | + parentURL, | ||
| 490 | + url: specifier, | ||
| 491 | + }); | ||
| 476 | 492 | } | |
| 477 | 493 | ||
| 478 | 494 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,3 +7,4 @@ Trace: foo | |||
| 7 | 7 | at * | |
| 8 | 8 | at * | |
| 9 | 9 | at * | |
| 10 | + at * | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,5 +11,6 @@ Error: Should include grayed stack trace | |||
| 11 | 11 | [90m at *[39m | |
| 12 | 12 | [90m at *[39m | |
| 13 | 13 | [90m at *[39m | |
| 14 | + [90m at *[39m | ||
| 14 | 15 | ||
| 15 | 16 | Node.js * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,5 +7,6 @@ | |||
| 7 | 7 | at * | |
| 8 | 8 | at * | |
| 9 | 9 | at * | |
| 10 | + at * | ||
| 10 | 11 | (Use `node --trace-warnings ...` to show where the warning was created) | |
| 11 | 12 | (node:*) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https:*nodejs.org*api*cli.html#cli_unhandled_rejections_mode). (rejection id: 1) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 11 | 11 | at * | |
| 12 | 12 | at * | |
| 13 | 13 | at * | |
| 14 | + at * | ||
| 14 | 15 | (node:*) Error: This was rejected | |
| 15 | 16 | at * | |
| 16 | 17 | at * | |
@@ -20,6 +21,7 @@ | |||
| 20 | 21 | at * | |
| 21 | 22 | at * | |
| 22 | 23 | at * | |
| 24 | + at * | ||
| 23 | 25 | (node:*) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1) | |
| 24 | 26 | at * | |
| 25 | 27 | at * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,7 @@ AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal: | |||
| 16 | 16 | at * | |
| 17 | 17 | at * | |
| 18 | 18 | at * | |
| 19 | + at * | ||
| 19 | 20 | at * { | |
| 20 | 21 | generatedMessage: true, | |
| 21 | 22 | code: 'ERR_ASSERTION', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ Please open an issue with this stack trace at https://github.com/nodejs/node/iss | |||
| 13 | 13 | at * | |
| 14 | 14 | at * | |
| 15 | 15 | at * | |
| 16 | + at * | ||
| 16 | 17 | at * { | |
| 17 | 18 | code: 'ERR_INTERNAL_ASSERTION' | |
| 18 | 19 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments