Skip to content

Commit 92b695e

Browse files
ofrobotstargos
authored andcommitted
trace_events: avoid flusing uninitialized traces
PR-URL: #22812 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
1 parent e85c814 commit 92b695e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/tracing/node_trace_buffer.cc

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ void InternalTraceBuffer::Flush(bool blocking) {
5959
for (size_t i = 0; i < total_chunks_; ++i) {
6060
auto& chunk = chunks_[i];
6161
for (size_t j = 0; j < chunk->size(); ++j) {
62-
agent_->AppendTraceEvent(chunk->GetEventAt(j));
62+
TraceObject* trace_event = chunk->GetEventAt(j);
63+
// Another thread may have added a trace that is yet to be
64+
// initialized. Skip such traces.
65+
// https://github.com/nodejs/node/issues/21038.
66+
if (trace_event->name()) {
67+
agent_->AppendTraceEvent(trace_event);
68+
}
6369
}
6470
}
6571
total_chunks_ = 0;

0 commit comments

Comments
 (0)