I am getting an error ReferenceError: performance is not defined
when trying to use performance.now() to measure the execution time of a function call:
export async function find(someId: string, ctx: context.IContext) {
try {
var t0 = performance.now();
var res = someModel.find(someId, ctx.cookies);
var t1 = performance.now();
console.log("Call to find took " + (t1 - t0) + " milliseconds.");
return res;
} catch (err) {
console.error(err);
throw err;
}
}
Any ideas how I can fix this?
For me it was on pristine next.js project, right after running installation wizard and adding apollo. Updating NODE to latest version solved the problem.
You can do with with
nvm use 18
or by adding a.nvmrc
file to the application.