@@ -3265,21 +3265,27 @@ void LoadEnvironment(Environment* env) {
32653265 env->isolate ()->SetFatalErrorHandler (node::OnFatalError);
32663266 env->isolate ()->AddMessageListener (OnMessage);
32673267
3268- // Compile, execute the src/node.js file. (Which was included as static C
3269- // string in node_natives.h. 'native_node' is the string containing that
3270- // source code.)
3271-
3272- // The node.js file returns a function 'f'
32733268 atexit (AtExit);
32743269
3270+ // Compile ./lib/internal/bootstrap_node.js as `Local<Function> f`.
3271+ // We call `f` at the end of this block with the 'process' variable
3272+ // built up with all our bindings. Inside the script we take care of
3273+ // assigning things to their places.
3274+
3275+ // We start the process this way in order to be more modular. Developers
3276+ // who do not like how bootrap_node.js sets up the module system but do like
3277+ // Node's I/O bindings may want to replace 'f' with their own function.
3278+
32753279 TryCatch try_catch (env->isolate ());
32763280
32773281 // Disable verbose mode to stop FatalException() handler from trying
32783282 // to handle the exception. Errors this early in the start-up phase
32793283 // are not safe to ignore.
32803284 try_catch.SetVerbose (false );
32813285
3282- Local<String> script_name = FIXED_ONE_BYTE_STRING (env->isolate (), " node.js" );
3286+ Local<String> script_name = FIXED_ONE_BYTE_STRING (env->isolate (),
3287+ " bootstrap_node.js" );
3288+
32833289 Local<Value> f_value = ExecuteString (env, MainSource (env), script_name);
32843290 if (try_catch.HasCaught ()) {
32853291 ReportException (env, try_catch);
@@ -3288,14 +3294,6 @@ void LoadEnvironment(Environment* env) {
32883294 CHECK (f_value->IsFunction ());
32893295 Local<Function> f = Local<Function>::Cast (f_value);
32903296
3291- // Now we call 'f' with the 'process' variable that we've built up with
3292- // all our bindings. Inside node.js we'll take care of assigning things to
3293- // their places.
3294-
3295- // We start the process this way in order to be more modular. Developers
3296- // who do not like how 'src/node.js' setups the module system but do like
3297- // Node's I/O bindings may want to replace 'f' with their own function.
3298-
32993297 // Add a reference to the global object
33003298 Local<Object> global = env->context ()->Global ();
33013299
@@ -4301,8 +4299,8 @@ static void StartNodeInstance(void* arg) {
43014299 v8::platform::PumpMessageLoop (default_platform, isolate);
43024300 EmitBeforeExit (env);
43034301
4304- // Emit `beforeExit` if the loop became alive either after emitting
4305- // event, or after running some callbacks.
4302+ // Check if the loop became alive either after emitting
4303+ // `beforeExit` event, or after running some callbacks.
43064304 more = uv_loop_alive (env->event_loop ());
43074305 if (uv_run (env->event_loop (), UV_RUN_NOWAIT) != 0 )
43084306 more = true ;
0 commit comments