fix: bootstrap the node environment after we setup the InspectorAgent (#19317)

This commit is contained in:
Samuel Attard 2019-07-18 16:54:23 -07:00 committed by GitHub
parent 2467350180
commit 6fc648cd25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 117 additions and 9 deletions

View file

@ -288,7 +288,8 @@ void NodeBindings::Initialize() {
node::Environment* NodeBindings::CreateEnvironment(
v8::Handle<v8::Context> context,
node::MultiIsolatePlatform* platform) {
node::MultiIsolatePlatform* platform,
bool bootstrap_env) {
#if defined(OS_WIN)
auto& atom_args = AtomCommandLine::argv();
std::vector<std::string> args(atom_args.size());
@ -327,13 +328,17 @@ node::Environment* NodeBindings::CreateEnvironment(
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
node::Environment* env = node::CreateEnvironment(
node::CreateIsolateData(context->GetIsolate(), uv_loop_, platform),
context, args.size(), c_argv.get(), 0, nullptr);
context, args.size(), c_argv.get(), 0, nullptr, bootstrap_env);
DCHECK(env);
// Clean up the global _noBrowserGlobals that we unironically injected into
// the global scope
if (browser_env_ != BrowserEnvironment::BROWSER)
if (browser_env_ != BrowserEnvironment::BROWSER) {
// We need to bootstrap the env in non-browser processes so that
// _noBrowserGlobals is read correctly before we remove it
DCHECK(bootstrap_env);
global.Delete("_noBrowserGlobals");
}
if (browser_env_ == BrowserEnvironment::BROWSER) {
// SetAutorunMicrotasks is no longer called in node::CreateEnvironment

View file

@ -41,9 +41,9 @@ class NodeBindings {
void Initialize();
// Create the environment and load node.js.
node::Environment* CreateEnvironment(
v8::Handle<v8::Context> context,
node::MultiIsolatePlatform* platform = nullptr);
node::Environment* CreateEnvironment(v8::Handle<v8::Context> context,
node::MultiIsolatePlatform* platform,
bool bootstrap_env);
// Load node.js in the environment.
void LoadEnvironment(node::Environment* env);