With Node.js 20, we are seeing a TypeError: The "this" argument must be an instance of Performance. error when using performance.now() from isomorphic-performance.
Steps to Reproduce:
npm install react-native-performance isomorphic-performance
node -p "require('isomorphic-performance').performance.now()" (with Node.js 20)
Actual Result:
TypeError [ERR_INVALID_ARG_TYPE]: The "this" argument must be an instance of Performance. Received undefined
at now (node:internal/perf/performance:139:5)
at createPerformance (/Users/marc/projects/zzz/react-native-performance/node_modules/react-native-performance/lib/commonjs/performance.js:17:22)
at Object.<anonymous> (/Users/marc/projects/zzz/react-native-performance/node_modules/isomorphic-performance/src/node.js:6:18)
Expected Result:
No error
Details:
This issue is caused by performance brand checks that were introduced in nodejs/node#44483. This is reproducible by running node -p "perf_hooks.performance.now.call()" with Node.js 20.
With Node.js 20, we are seeing a
TypeError: The "this" argument must be an instance of Performance.error when usingperformance.now()fromisomorphic-performance.Steps to Reproduce:
npm install react-native-performance isomorphic-performancenode -p "require('isomorphic-performance').performance.now()"(with Node.js 20)Actual Result:
TypeError [ERR_INVALID_ARG_TYPE]: The "this" argument must be an instance of Performance. Received undefined at now (node:internal/perf/performance:139:5) at createPerformance (/Users/marc/projects/zzz/react-native-performance/node_modules/react-native-performance/lib/commonjs/performance.js:17:22) at Object.<anonymous> (/Users/marc/projects/zzz/react-native-performance/node_modules/isomorphic-performance/src/node.js:6:18)Expected Result:
No error
Details:
This issue is caused by
performancebrand checks that were introduced in nodejs/node#44483. This is reproducible by runningnode -p "perf_hooks.performance.now.call()"with Node.js 20.