Skip to content
Merged
Changes from 1 commit
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
28 changes: 18 additions & 10 deletions src/node_snapshotable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -973,25 +973,33 @@ ExitCode BuildSnapshotWithoutCodeCache(
}
});

Context::Scope context_scope(setup->context());
Environment* env = setup->env();

// Run the custom main script for fully customized snapshots.
if (snapshot_type == SnapshotMetadata::Type::kFullyCustomized) {
Context::Scope context_scope(setup->context());
Environment* env = setup->env();
#if HAVE_INSPECTOR
env->InitializeInspector({});
#endif
if (LoadEnvironment(env, builder_script_content.value()).IsEmpty()) {
return ExitCode::kGenericUserError;
}
}

// FIXME(joyeecheung): right now running the loop in the snapshot
// builder might introduce inconsistencies in JS land that need to
// be synchronized again after snapshot restoration.
ExitCode exit_code =
SpinEventLoopInternal(env).FromMaybe(ExitCode::kGenericUserError);
if (exit_code != ExitCode::kNoFailure) {
return exit_code;
}
// Drain the loop and platform tasks before creating a snapshot. This is
// necessary to ensure that the no roots are held by the the platform
// tasks, which may reference objects associated with a context. For
// example, a WeakRef may schedule an per-isolate platform task as a GC
// root, and referencing an object in a context, causing an assertion in
// the snapshot creator.

// FIXME(joyeecheung): right now running the loop in the snapshot
// builder might introduce inconsistencies in JS land that need to
// be synchronized again after snapshot restoration.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// FIXME(joyeecheung): right now running the loop in the snapshot
// builder might introduce inconsistencies in JS land that need to
// be synchronized again after snapshot restoration.
// FIXME(joyeecheung): right now running the loop in the snapshot
// builder might introduce inconsistencies in JS land that need to
// be synchronized again after snapshot restoration.

This should be removed now - I remember I left it because I found some inconsistencies if this was done for the built-in snapshot. But that was quite some time ago and we probably have done enough cleanup in the bootstrap path to make it viable - if the tests are clean now, maybe it's okay to run the event loop for the built-in snapshot too now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

ExitCode exit_code =
SpinEventLoopInternal(env).FromMaybe(ExitCode::kGenericUserError);
if (exit_code != ExitCode::kNoFailure) {
return exit_code;
}
}

Expand Down
Loading