Skip to content

SyntaxError in node:perf_hooks documentation #60368

@davidebombelli

Description

@davidebombelli

Affected URL(s)

https://nodejs.org/api/perf_hooks.html#performanceeventlooputilizationutilization1-utilization2

Description of the problem

I saved the example code in a file test.mjs:

import { eventLoopUtilization } from 'node:perf_hooks';
import { spawnSync } from 'node:child_process';

setImmediate(() => {
  const elu = eventLoopUtilization();
  spawnSync('sleep', ['5']);
  console.log(eventLoopUtilization(elu).utilization);
});

Upon running node test.mjs, an exception is thrown:
SyntaxError: The requested module 'node:perf_hooks' does not provide an export named 'eventLoopUtilization'

However, importing performance works:

import { performance } from 'node:perf_hooks';
import { spawnSync } from 'node:child_process';

setImmediate(() => {
  const elu = performance.eventLoopUtilization();
  spawnSync('sleep', ['5']);
  console.log(performance.eventLoopUtilization(elu).utilization);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.perf_hooksIssues and PRs related to the implementation of the Performance Timing API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions