Skip to content

Commit 8398bf9

Browse files
committed
debugger: assign Environment to DebugContext too
fix nodejs#7517
1 parent 9479399 commit 8398bf9

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/node.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3093,6 +3093,9 @@ static void EnableDebug(Isolate* isolate, bool wait_connect) {
30933093
if (env == NULL)
30943094
return; // Still starting up.
30953095

3096+
// Assign environment to the debugger's context
3097+
env->AssignToContext(v8::Debug::GetDebugContext());
3098+
30963099
Context::Scope context_scope(env->context());
30973100
Local<Object> message = Object::New(env->isolate());
30983101
message->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "cmd"),
@@ -3594,6 +3597,11 @@ int Start(int argc, char** argv) {
35943597
Locker locker(node_isolate);
35953598
Environment* env =
35963599
CreateEnvironment(node_isolate, argc, argv, exec_argc, exec_argv);
3600+
// Assign env to the debugger's context
3601+
if (debugger_running) {
3602+
HandleScope scope(env->isolate());
3603+
env->AssignToContext(v8::Debug::GetDebugContext());
3604+
}
35973605
// This Context::Scope is here so EnableDebug() can look up the current
35983606
// environment with Environment::GetCurrentChecked().
35993607
// TODO(bnoordhuis) Reorder the debugger initialization logic so it can

test/debugger/test-debugger-repl.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,13 @@ addTest('c', [
7474
/\d/, /\d/, /\d/, /\d/, /\d/
7575
]);
7676

77-
addTest('quit', []);
77+
// REPL and process.env regression
78+
addTest('repl', [
79+
/Ctrl/
80+
]);
81+
82+
addTest('for (var i in process.env) delete process.env[i]', []);
83+
84+
addTest('process.env', [
85+
/\{\}/
86+
]);

0 commit comments

Comments
 (0)