diff options
-rw-r--r-- | cli/tests/node_compat/config.json | 2 | ||||
-rw-r--r-- | ext/node/polyfills/process.ts | 9 |
2 files changed, 9 insertions, 2 deletions
diff --git a/cli/tests/node_compat/config.json b/cli/tests/node_compat/config.json index 5bf150d9b..85e5f09c5 100644 --- a/cli/tests/node_compat/config.json +++ b/cli/tests/node_compat/config.json @@ -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", diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index 42c55ccc5..779eefb8c 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -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; }; |