Skip to content
Permalink
Browse files

fix: make process.uptime() return the correct time

  • Loading branch information...
Micha Hanselmann
Micha Hanselmann committed Jul 30, 2019
1 parent 0f78f8a commit 0af8a548a5916cc9c42ee8d40c11dd15b3602610
@@ -54,3 +54,4 @@ fix_ensure_js2c_maps_internal-fs_streams.patch
chore_read_nobrowserglobals_from_global_not_process.patch
chore_use_v8_inspector_js_protocol_to_find_pdl_file.patch
chore_split_createenvironment_into_createenvironment_and.patch
fix_set_uptime_offset_in_correct_init_method.patch
@@ -8,7 +8,7 @@ This allows us to run operations on a created but not yet bootstrapped
environment such as setting up an InspectorAgent

diff --git a/src/api/environment.cc b/src/api/environment.cc
index e313460a13ced7e7a9982db6f4a988699ec56111..faeba6d4e687261df1a58ad3c1e14d53b0e6d832 100644
index e313460a13ced7e7a9982db6f4a988699ec56111..51353924cb0aef2a61f4aa799b6a90326c7a65ad 100644
--- a/src/api/environment.cc
+++ b/src/api/environment.cc
@@ -269,7 +269,8 @@ Environment* CreateEnvironment(IsolateData* isolate_data,
@@ -0,0 +1,29 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Micha Hanselmann <deermichel@github.com>
Date: Thu, 1 Aug 2019 09:59:48 -0700
Subject: fix: set uptime offset in correct init method

This patch can be removed after 'https://github.com/nodejs/node/pull/28849' landed here.

diff --git a/src/node.cc b/src/node.cc
index c0a8bdd28a403b399f2766e40b2fe90e76fca849..193a4b3e91a744b6934658f531b2f46698ad8323 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -624,6 +624,9 @@ int InitializeNodeWithArgs(std::vector<std::string>* argv,
// Make sure InitializeNodeWithArgs() is called only once.
CHECK(!init_called.exchange(true));

+ // Initialize node_start_time to get relative uptime.
+ per_process::node_start_time = uv_hrtime();
+
// Register built-in modules
binding::RegisterBuiltinModules();

@@ -810,7 +813,6 @@ void Init(int* argc,
InitializationResult InitializeOncePerProcess(int argc, char** argv) {
atexit([] () { uv_tty_reset_mode(); });
PlatformInit();
- per_process::node_start_time = uv_hrtime();

CHECK_GT(argc, 0);

0 comments on commit 0af8a54

Please sign in to comment.
You can’t perform that action at this time.