Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspector: fix inspector open when there are sessions #46950

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/inspector_agent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,10 @@ bool Agent::IsActive() {
return io_ != nullptr || client_->IsActive();
}

bool Agent::HasInspectorThread() {
return io_ != nullptr;
}

void Agent::SetParentHandle(
std::unique_ptr<ParentInspectorHandle> parent_handle) {
parent_handle_ = std::move(parent_handle);
Expand Down
2 changes: 2 additions & 0 deletions src/inspector_agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Agent {
// --inspect command line flag) or if inspector JS API had been used.
bool IsActive();

bool HasInspectorThread();

// Blocks till frontend connects and sends "runIfWaitingForDebugger"
void WaitForConnect();
// Blocks till all the sessions with "WaitForDisconnectOnShutdown" disconnect
Expand Down
2 changes: 1 addition & 1 deletion src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static void RegisterAsyncHookWrapper(const FunctionCallbackInfo<Value>& args) {

void IsEnabled(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
args.GetReturnValue().Set(InspectorEnabled(env));
args.GetReturnValue().Set(env->inspector_agent()->HasInspectorThread());
}

void Open(const FunctionCallbackInfo<Value>& args) {
Expand Down
13 changes: 13 additions & 0 deletions test/sequential/test-inspector-open-with-session.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

const common = require('../common');
common.skipIfInspectorDisabled();

const { open, url } = require("inspector");
const { Session } = require('inspector');
const assert = require('assert');
const session = new Session();
session.connect();

open();
assert.ok(url() !== undefined);