Skip to content

SyntaxError in node:perf_hooks documentation #60368

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);
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions