0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(ext/node): fix process.uptime (#17839)

This commit is contained in:
Yoshiya Hinosawa 2023-02-22 00:14:15 +09:00 committed by GitHub
parent 914b08fc19
commit 608c855f11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View file

@ -540,7 +540,7 @@
"test-process-exit-recursive.js",
"test-process-exit.js",
"test-process-kill-pid.js",
"TODO:test-process-uptime.js",
"test-process-uptime.js",
"test-promise-unhandled-silent.js",
"test-promise-unhandled-throw-handler.js",
"TODO:test-punycode.js",

View file

@ -647,7 +647,11 @@ class Process extends EventEmitter {
execPath = path;
}
#startTime = Date.now();
setStartTime(t: number) {
this.#startTime = t;
}
#startTime = 0;
/** https://nodejs.org/api/process.html#processuptime */
uptime() {
return (Date.now() - this.#startTime) / 1000;
@ -762,6 +766,9 @@ internals.__bootstrapNodeProcess = function (
"stdout",
);
process.setStartTime(Date.now());
// @ts-ignore Remove setStartTime and #startTime is not modifiable
delete process.setStartTime;
delete internals.__bootstrapNodeProcess;
};