Skip to content

Commit ba3aa1b

Browse files
CezaryKulakowskit57ser
authored andcommitted
fix: event with invalid timestamp in trace log (electron#31349)
When node is started within Electron's environment it doesn't initialize v8 and time of v8's start is never set. As a result we log v8's start time as 0 and it breaks timestamps in the trace log. With this change we log v8's start time only when it was initialized by node.
1 parent 5b8beff commit ba3aa1b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

patches/node/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ add_should_read_node_options_from_env_option_to_disable_node_options.patch
2323
repl_fix_crash_when_sharedarraybuffer_disabled.patch
2424
fix_readbarrier_undefined_symbol_error_on_woa_arm64.patch
2525
chore_fix_-wimplicit-fallthrough.patch
26+
fix_event_with_invalid_timestamp_in_trace_log.patch
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Cezary Kulakowski <[email protected]>
3+
Date: Fri, 8 Oct 2021 11:18:58 +0200
4+
Subject: fix: event with invalid timestamp in trace log
5+
6+
When node is started within Electron's environment it doesn't
7+
initialize v8 and time of v8's start is never set. As a result
8+
we log v8's start time as 0 and it breaks timestamps in the
9+
trace log. With this change we log v8's start time only when
10+
it was initialized by node.
11+
12+
diff --git a/src/env.cc b/src/env.cc
13+
index 16af6aec3791df1363682f1ed024c52208b9a8f6..ada0faa93bc223ffbea79a4308796df73ea8ae4e 100644
14+
--- a/src/env.cc
15+
+++ b/src/env.cc
16+
@@ -461,8 +461,10 @@ void Environment::InitializeMainContext(Local<Context> context,
17+
environment_start_time_);
18+
performance_state_->Mark(performance::NODE_PERFORMANCE_MILESTONE_NODE_START,
19+
per_process::node_start_time);
20+
- performance_state_->Mark(performance::NODE_PERFORMANCE_MILESTONE_V8_START,
21+
- performance::performance_v8_start);
22+
+ if (per_process::v8_initialized) {
23+
+ performance_state_->Mark(performance::NODE_PERFORMANCE_MILESTONE_V8_START,
24+
+ performance::performance_v8_start);
25+
+ }
26+
}
27+
28+
Environment::~Environment() {

0 commit comments

Comments
 (0)