diff --git a/lib/internal/main/mksnapshot.js b/lib/internal/main/mksnapshot.js index e194bbc6004f37..d49b9c1e6cbfc9 100644 --- a/lib/internal/main/mksnapshot.js +++ b/lib/internal/main/mksnapshot.js @@ -107,4 +107,9 @@ const mainFile = readFileSync(getOptionValue('--snapshot-main'), 'utf-8'); const snapshotMainFunction = compileSnapshotMain(mainFile); -snapshotMainFunction(requireForUserSnapshot); +if (getOptionValue('--inspect-brk')) { + internalBinding('inspector').callAndPauseOnStart( + snapshotMainFunction, undefined, requireForUserSnapshot); +} else { + snapshotMainFunction(requireForUserSnapshot); +} diff --git a/src/node_snapshotable.cc b/src/node_snapshotable.cc index cb6c3dca451791..9f8c6263823e04 100644 --- a/src/node_snapshotable.cc +++ b/src/node_snapshotable.cc @@ -13,6 +13,10 @@ #include "node_v8.h" #include "node_v8_platform-inl.h" +#if HAVE_INSPECTOR +#include "inspector/worker_inspector.h" // ParentInspectorHandle +#endif + namespace node { using v8::Context; @@ -577,6 +581,10 @@ void SnapshotBuilder::Generate(SnapshotData* out, nullptr, node::EnvironmentFlags::kDefaultFlags, {}); + +#if HAVE_INSPECTOR + env->InitializeInspector({}); +#endif // Run scripts in lib/internal/bootstrap/ { TryCatch bootstrapCatch(isolate); @@ -602,8 +610,8 @@ void SnapshotBuilder::Generate(SnapshotData* out, // FIXME(joyee): right now running the loop in the snapshot builder // seems to intrudoces inconsistencies in JS land that need to be // synchronized again after snapshot restoration. - // int exit_code = SpinEventLoop(env).FromMaybe(1); - // CHECK_EQ(exit_code, 0); + int exit_code = SpinEventLoop(env).FromMaybe(1); + CHECK_EQ(exit_code, 0); } if (per_process::enabled_debug_list.enabled(DebugCategory::MKSNAPSHOT)) {