Skip to content

Commit 9fc4b9b

Browse files
joyeecheungbengl
authored andcommitted
src: include internal/options in the snapshot
This patch enables internal/options to be included in the snapshot, so that when lazy loading the run time options, the modules only need to make sure that the options are queried lazily and do not have to lazy load the internal/options module together. We can still guarantee that no run time options are serialized into the state-independent bootstrap snapshot with the assertion inside GetCLIOptions(). PR-URL: #42203 Refs: #37476 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent fe01940 commit 9fc4b9b

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/internal/bootstrap/node.js

+1
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ require('fs');
391391
require('v8');
392392
require('vm');
393393
require('url');
394+
require('internal/options');
394395

395396
function setupPrepareStackTrace() {
396397
const {

src/node_external_reference.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ExternalReferenceRegistry {
6767
V(heap_utils) \
6868
V(messaging) \
6969
V(native_module) \
70+
V(options) \
7071
V(os) \
7172
V(performance) \
7273
V(process_methods) \

src/node_options.cc

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "env-inl.h"
55
#include "node_binding.h"
6+
#include "node_external_reference.h"
67
#include "node_internals.h"
78
#if HAVE_OPENSSL
89
#include "openssl/opensslv.h"
@@ -1132,6 +1133,10 @@ void Initialize(Local<Object> target,
11321133
.Check();
11331134
}
11341135

1136+
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
1137+
registry->Register(GetCLIOptions);
1138+
registry->Register(GetEmbedderOptions);
1139+
}
11351140
} // namespace options_parser
11361141

11371142
void HandleEnvOptions(std::shared_ptr<EnvironmentOptions> env_options) {
@@ -1198,3 +1203,5 @@ std::vector<std::string> ParseNodeOptionsEnvVar(
11981203
} // namespace node
11991204

12001205
NODE_MODULE_CONTEXT_AWARE_INTERNAL(options, node::options_parser::Initialize)
1206+
NODE_MODULE_EXTERNAL_REFERENCE(options,
1207+
node::options_parser::RegisterExternalReferences)

0 commit comments

Comments
 (0)