How to fix TypeError: Unknown entry type 'invalid-type' in Node.js

Node.jsINTERMEDIATEMEDIUMUpdated Dec 9, 2025· 92 views

This error occurs when you pass an invalid entry type to PerformanceObserver.observe() in Node.js's perf_hooks module. The observer only accepts specific, predefined entry types.

Quick fix

Fixes ERR_INVALID_ARG_VALUE

// ❌ WRONG - typo in entry type
const obs = new PerformanceObserver((list) => {
  console.log(list.getEntries());
});
obs.observe({ entryTypes: ['measur'] }); // TypeError!

// ✅ CORRECT - proper spelling
obs.observe({ entryTypes: ['measure'] });
  1. Verify the entry type string against Node.js documentation
  2. Check for typos in your observer configuration
  3. Use type or entryTypes correctly, not both
  4. Check Node.js version compatibility
node.js — error
// ❌ WRONG - typo in entry type
const obs = new PerformanceObserver((list) => {
console.log(list.getEntries());
});
obs.observe({ entryTypes: ['measur'] }); // TypeError!
// ✅ CORRECT - proper spelling
obs.observe({ entryTypes: ['measure'] });
TypeError: Unknown entry type 'invalid-type'

What this error means

This TypeError is thrown by Node.js's `perf_hooks` module when you attempt to observe a performance entry type that doesn't exist or isn't supported. The PerformanceObserver API is designed to watch specific performance metrics like marks, measures, and garbage collection events, but it only accepts a predefined set of entry type strings. When you call `observe()` with an invalid entry type in the `type` or `entryTypes` option, Node.js validates the provided string against its internal list of supported types. If the type doesn't match any known entry type, it throws this TypeError immediately. This is a safeguard to catch typos and configuration errors early, preventing you from setting up observers that would never receive any performance data.

Typical symptoms

  • TypeError thrown immediately when calling PerformanceObserver.observe()
  • Error message shows the exact invalid entry type string you provided
  • Performance monitoring code fails to initialize
  • Application crashes on startup if performance observer setup is in initialization code
  • No performance entries are captured despite observer being created

Common causes

  1. Typo in the entry type string (e.g., 'measur' instead of 'measure')
  2. Using a browser-specific entry type in Node.js (e.g., 'navigation' or 'resource' may not be available)
  3. Attempting to use an entry type from a newer Node.js version in an older runtime
  4. Passing a custom string that you expect to work as an entry type
  5. Case sensitivity issue (entry types are case-sensitive)
  6. Using deprecated entry types that were removed in a Node.js update

How to fix "TypeError: Unknown entry type 'invalid-type'"

1Verify the entry type string against Node.js documentation

Check the [Node.js perf_hooks documentation](https://nodejs.org/api/perf_hooks.html) for your specific Node.js version to see all supported entry types.

Common valid entry types in Node.js include:
- 'mark' - Performance marks created with performance.mark()
- 'measure' - Performance measures created with performance.measure()
- 'function' - Function execution timing
- 'gc' - Garbage collection events
- 'http' - HTTP request/response timing
- 'http2' - HTTP/2 request/response timing
- 'dns' - DNS lookup timing

If you're using a type not in this list, verify it exists in your Node.js version.

2Check for typos in your observer configuration

Review your observe() call for spelling errors:

typescript
// ❌ WRONG - typo in entry type
const obs = new PerformanceObserver((list) => {
  console.log(list.getEntries());
});
obs.observe({ entryTypes: ['measur'] }); // TypeError!

// ✅ CORRECT - proper spelling
obs.observe({ entryTypes: ['measure'] });

Entry types are case-sensitive, so 'Measure' or 'MEASURE' won't work.

3Use type or entryTypes correctly, not both

The observe() method accepts either type (string) or entryTypes (array), but not both:

typescript
// ✅ CORRECT - using type (single entry)
obs.observe({ type: 'measure' });

// ✅ CORRECT - using entryTypes (multiple entries)
obs.observe({ entryTypes: ['mark', 'measure'] });

// ❌ WRONG - mixing both options
obs.observe({
  type: 'measure',
  entryTypes: ['mark', 'measure']
});

If you use type, provide a single string. If you use entryTypes, provide an array of strings.

4Check Node.js version compatibility

Some entry types were added in specific Node.js versions. Check your Node.js version:

bash
node --version

Then verify the entry type is supported in that version. For example:
- 'http' and 'http2' were added in later versions
- Some experimental entry types may require specific flags

If you need a newer entry type, consider:
- Upgrading Node.js to a version that supports it
- Using a fallback or alternative monitoring approach
- Wrapping the observer setup in a try-catch with version detection

5Test with a minimal example

Create a simple test to isolate the issue:

typescript
import { PerformanceObserver } from 'perf_hooks';

// Test each entry type individually
const validTypes = ['mark', 'measure', 'function', 'gc'];

validTypes.forEach((type) => {
  try {
    const obs = new PerformanceObserver((list) => {
      console.log(`${type} entries:`, list.getEntries());
    });
    obs.observe({ type });
    console.log(`✓ ${type} is supported`);
  } catch (err) {
    console.error(`✗ ${type} failed:`, err.message);
  }
});

This will show you exactly which entry types work in your environment.

Advanced notes

Entry Type Availability by Context

Not all entry types are available in every Node.js context:
- 'gc' entries require the --expose-gc flag or calling performance.gc() with appropriate permissions
- 'dns' entries are only emitted for DNS operations performed through Node.js's dns module
- 'http' and 'http2' entries require using Node.js's built-in HTTP modules

Performance Impact Considerations

When setting up performance observers:
- Observing 'gc' can have overhead as it tracks every garbage collection cycle
- Using buffered: true retrieves past entries, which may include many items
- Multiple observers watching the same entry types each create separate callback invocations

Dynamic Entry Type Validation

For production code that needs to work across Node.js versions, implement dynamic validation:

typescript
import { PerformanceObserver, constants } from 'perf_hooks';

function supportsEntryType(type: string): boolean {
  try {
    const obs = new PerformanceObserver(() => {});
    obs.observe({ type });
    obs.disconnect();
    return true;
  } catch {
    return false;
  }
}

// Use this to conditionally set up observers
const entryTypes = ['mark', 'measure', 'gc'].filter(supportsEntryType);
if (entryTypes.length > 0) {
  const obs = new PerformanceObserver((list) => {
    // Handle entries
  });
  obs.observe({ entryTypes });
}

This approach ensures your monitoring code degrades gracefully rather than crashing on unsupported entry types.

Frequently asked questions

What does "ERR_INVALID_ARG_VALUE" mean?
js's perf_hooks module when you attempt to observe a performance entry type that doesn't exist or isn't supported. The PerformanceObserver API is designed to watch specific performance metrics like marks, measures, and garbage collection events, but it only accepts a predefined set of entry type strings. js validates the provided string against its internal list of supported types.
How do I fix "ERR_INVALID_ARG_VALUE"?
This error occurs when you pass an invalid entry type to PerformanceObserver.observe() in Node.js's perf_hooks module. The observer only accepts specific, predefined entry types.
What causes "ERR_INVALID_ARG_VALUE"?
Typo in the entry type string (e.g., 'measur' instead of 'measure') Using a browser-specific entry type in Node.js (e.g., 'navigation' or 'resource' may not be available) Attempting to use an entry type from a newer Node.js version in an older runtime
Is the "ERR_INVALID_ARG_VALUE" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading