diff --git a/src/inspector_profiler.cc b/src/inspector_profiler.cc index d51c58a43c28fe..46d4c4fec8d19e 100644 --- a/src/inspector_profiler.cc +++ b/src/inspector_profiler.cc @@ -194,8 +194,8 @@ void V8CpuProfilerConnection::OnMessage( return; } Isolate* isolate = env()->isolate(); - Local context = env()->context(); HandleScope handle_scope(isolate); + Local context = env()->context(); Context::Scope context_scope(context); Local result; if (!String::NewFromTwoByte(isolate, @@ -203,12 +203,12 @@ void V8CpuProfilerConnection::OnMessage( NewStringType::kNormal, message.length()) .ToLocal(&result)) { - fprintf(stderr, "Failed to covert profiling message\n"); + fprintf(stderr, "Failed to convert profiling message\n"); } WriteCpuProfile(result); } -bool V8CpuProfilerConnection::WriteCpuProfile(Local message) { +void V8CpuProfilerConnection::WriteCpuProfile(Local message) { const std::string& path = env()->cpu_profile_path(); CHECK(!path.empty()); std::string directory = path.substr(0, path.find_last_of(kPathSeparator)); @@ -223,14 +223,13 @@ bool V8CpuProfilerConnection::WriteCpuProfile(Local message) { "%s: Failed to create cpu profile directory %s\n", err_buf, directory.c_str()); - return false; + return; } } MaybeLocal result = GetResult(message); - if (result.IsEmpty()) { - return false; + if (!result.IsEmpty()) { + WriteResult(path.c_str(), result.ToLocalChecked()); } - return WriteResult(path.c_str(), result.ToLocalChecked()); } MaybeLocal V8CpuProfilerConnection::GetResult(Local message) { diff --git a/src/inspector_profiler.h b/src/inspector_profiler.h index b4db1392c9b9a8..7120819c13b070 100644 --- a/src/inspector_profiler.h +++ b/src/inspector_profiler.h @@ -79,7 +79,7 @@ class V8CpuProfilerConnection : public V8ProfilerConnection { bool ending() const override { return ending_; } private: - bool WriteCpuProfile(v8::Local message); + void WriteCpuProfile(v8::Local message); v8::MaybeLocal GetResult(v8::Local message); std::unique_ptr session_; diff --git a/test/sequential/test-cpu-prof.js b/test/sequential/test-cpu-prof.js index ce4fc2e0c84ab0..a13db4ac10ef4e 100644 --- a/test/sequential/test-cpu-prof.js +++ b/test/sequential/test-cpu-prof.js @@ -35,9 +35,19 @@ function verifyFrames(output, file, suffix) { assert.notDeepStrictEqual(frames, []); } +let FIB = 30; +// This is based on emperial values - in the CI, on Windows the program +// tend to finish too fast then we won't be able to see the profiled script +// in the samples, so we need to bump the values a bit. On slower platforms +// like the Pis it could take more time to complete, we need to use a +// smaller value so the test would not time out. +if (common.isWindows) { + FIB = 40; +} + const env = { ...process.env, - FIB: 35, + FIB, NODE_DEBUG_NATIVE: 'INSPECTOR_PROFILER' };