Skip to content

Commit

Permalink
fixup! src: reorganize inspector and diagnostics initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung committed Jun 1, 2019
1 parent 1de0c1a commit bd13830
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -799,12 +799,13 @@ class Environment : public MemoryRetainer {
void MemoryInfo(MemoryTracker* tracker) const override;

void CreateProperties();
// Should be called before InitializeInspector()
void InitializeDiagnostics();
#if HAVE_INSPECTOR && NODE_USE_V8_PLATFORM
// If the environment is created for a worker, pass parent_handle and
// the ownership if transferred into the Environment.
int InitializeInspector(inspector::ParentInspectorHandle* parent_handle);
#endif
void InitializeDiagnostics();

v8::MaybeLocal<v8::Value> BootstrapInternalLoaders();
v8::MaybeLocal<v8::Value> BootstrapNode();
Expand Down
1 change: 1 addition & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ int Environment::InitializeInspector(
} else {
inspector_path = argv_.size() > 1 ? argv_[1].c_str() : "";
}

CHECK(!inspector_agent_->IsListening());
// Inspector agent can't fail to start, but if it was configured to listen
// right away on the websocket port and fails to bind/etc, this will return
Expand Down
2 changes: 1 addition & 1 deletion src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment(
Environment::kOwnsProcessState |
Environment::kOwnsInspector));
env->InitializeLibuv(per_process::v8_is_profiling);
env->InitializeDiagnostics();

// TODO(joyeecheung): when we snapshot the bootstrapped context,
// the inspector and diagnostics setup should after after deserialization.
Expand All @@ -204,7 +205,6 @@ std::unique_ptr<Environment> NodeMainInstance::CreateMainEnvironment(
return env;
}

env->InitializeDiagnostics();
if (env->RunBootstrapping().IsEmpty()) {
*exit_code = 1;
}
Expand Down
3 changes: 1 addition & 2 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ Worker::Worker(Environment* env,
per_isolate_opts_(per_isolate_opts),
exec_argv_(exec_argv),
platform_(env->isolate_data()->platform()),
// XXX(joyeecheung): should this be per_process::v8_is_profiling instead?
start_profiler_idle_notifier_(env->profiler_idle_notifier_started()),
thread_id_(Environment::AllocateThreadId()),
env_vars_(env->env_vars()) {
Expand Down Expand Up @@ -263,11 +262,11 @@ void Worker::Run() {
Debug(this, "Created Environment for worker with id %llu", thread_id_);
if (is_stopped()) return;
{
env_->InitializeDiagnostics();
#if NODE_USE_V8_PLATFORM && HAVE_INSPECTOR
env_->InitializeInspector(inspector_parent_handle_.release());
inspector_started = true;
#endif
env_->InitializeDiagnostics();
HandleScope handle_scope(isolate_);
AsyncCallbackScope callback_scope(env_.get());
env_->async_hooks()->push_async_ids(1, 0);
Expand Down

0 comments on commit bd13830

Please sign in to comment.