mirror of
https://github.com/denoland/deno.git
synced 2025-02-08 07:16:56 -05:00
fix(ext/node): process.uptime works without this (#23786)
Fixes https://github.com/denoland/deno/issues/23761 Co-authored-by: Satya Rohith <me@satyarohith.com>
This commit is contained in:
parent
99babe580f
commit
eca12e0eb8
2 changed files with 10 additions and 10 deletions
|
@ -668,14 +668,9 @@ class Process extends EventEmitter {
|
||||||
execPath = path;
|
execPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
setStartTime(t: number) {
|
|
||||||
this.#startTime = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
#startTime = 0;
|
|
||||||
/** https://nodejs.org/api/process.html#processuptime */
|
/** https://nodejs.org/api/process.html#processuptime */
|
||||||
uptime() {
|
uptime() {
|
||||||
return (Date.now() - this.#startTime) / 1000;
|
return Number((performance.now() / 1000).toFixed(9));
|
||||||
}
|
}
|
||||||
|
|
||||||
#allowedFlags = buildAllowedFlags();
|
#allowedFlags = buildAllowedFlags();
|
||||||
|
@ -887,16 +882,12 @@ internals.__bootstrapNodeProcess = function (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
process.setStartTime(Date.now());
|
|
||||||
|
|
||||||
arch = arch_();
|
arch = arch_();
|
||||||
platform = isWindows ? "win32" : Deno.build.os;
|
platform = isWindows ? "win32" : Deno.build.os;
|
||||||
pid = Deno.pid;
|
pid = Deno.pid;
|
||||||
|
|
||||||
initializeDebugEnv(nodeDebug);
|
initializeDebugEnv(nodeDebug);
|
||||||
|
|
||||||
// @ts-ignore Remove setStartTime and #startTime is not modifiable
|
|
||||||
delete process.setStartTime;
|
|
||||||
delete internals.__bootstrapNodeProcess;
|
delete internals.__bootstrapNodeProcess;
|
||||||
} else {
|
} else {
|
||||||
// Warmup, assuming stdin/stdout/stderr are all terminals
|
// Warmup, assuming stdin/stdout/stderr are all terminals
|
||||||
|
|
|
@ -1083,3 +1083,12 @@ Deno.test({
|
||||||
process.setSourceMapsEnabled(true); // noop
|
process.setSourceMapsEnabled(true); // noop
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Regression test for https://github.com/denoland/deno/issues/23761
|
||||||
|
Deno.test({
|
||||||
|
name: "process.uptime without this",
|
||||||
|
fn() {
|
||||||
|
const v = (0, process.uptime)();
|
||||||
|
assert(v >= 0);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue