Skip to content

Commit 37e576c

Browse files
committed
vfs: restore isExperimentalSeaWarningNeeded as a function
Reverts the change that converted isExperimentalSeaWarningNeeded from a SetMethod (function) to a boolean property in the sea binding. This keeps mksnapshot.js unchanged from upstream.
1 parent 580bc2a commit 37e576c

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

lib/internal/main/embedding.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ const path = require('path');
3737
// command line (e.g. it could be provided via an API or bundled into the executable).
3838
prepareMainThreadExecution(false, true);
3939

40-
const isBuiltinWarningNeeded = isLoadingSea && isExperimentalSeaWarningNeeded;
41-
if (isExperimentalSeaWarningNeeded) {
40+
const isBuiltinWarningNeeded = isLoadingSea && isExperimentalSeaWarningNeeded();
41+
if (isExperimentalSeaWarningNeeded()) {
4242
emitExperimentalWarning('Single executable application');
4343
}
4444

lib/internal/main/mksnapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function main() {
202202
return fn(requireForUserSnapshot, filename, dirname);
203203
}
204204

205-
if (isExperimentalSeaWarningNeeded) {
205+
if (isExperimentalSeaWarningNeeded()) {
206206
emitExperimentalWarning('Single executable application');
207207
}
208208

lib/internal/modules/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ let isSEABuiltinWarningNeeded_;
144144
function isSEABuiltinWarningNeeded() {
145145
if (isSEABuiltinWarningNeeded_ === undefined) {
146146
const { isExperimentalSeaWarningNeeded, isSea } = internalBinding('sea');
147-
isSEABuiltinWarningNeeded_ = isSea && isExperimentalSeaWarningNeeded;
147+
isSEABuiltinWarningNeeded_ = isSea && isExperimentalSeaWarningNeeded();
148148
}
149149
return isSEABuiltinWarningNeeded_;
150150
}

src/node_sea.cc

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,23 @@ SeaResource FindSingleExecutableResource() {
259259
return sea_resource;
260260
}
261261

262-
// Boolean flag getters removed - flags are set as properties in Initialize().
262+
void IsExperimentalSeaWarningNeeded(const FunctionCallbackInfo<Value>& args) {
263+
bool is_building_sea =
264+
!per_process::cli_options->experimental_sea_config.empty();
265+
if (is_building_sea) {
266+
args.GetReturnValue().Set(true);
267+
return;
268+
}
269+
270+
if (!IsSingleExecutable()) {
271+
args.GetReturnValue().Set(false);
272+
return;
273+
}
274+
275+
SeaResource sea_resource = FindSingleExecutableResource();
276+
args.GetReturnValue().Set(!static_cast<bool>(
277+
sea_resource.flags & SeaFlags::kDisableExperimentalSeaWarning));
278+
}
263279

264280
std::tuple<int, char**> FixupArgsForSEA(int argc, char** argv) {
265281
// Repeats argv[0] at position 1 on argv as a replacement for the missing
@@ -886,17 +902,11 @@ void Initialize(Local<Object> target,
886902
// Set boolean flags as properties (computed once, avoids repeated calls).
887903
bool is_sea = IsSingleExecutable();
888904
bool is_vfs_enabled = false;
889-
bool is_experimental_warning_needed =
890-
!per_process::cli_options->experimental_sea_config.empty();
891905

892906
if (is_sea) {
893907
SeaResource sea_resource = FindSingleExecutableResource();
894908
is_vfs_enabled =
895909
static_cast<bool>(sea_resource.flags & SeaFlags::kEnableVfs);
896-
if (!static_cast<bool>(sea_resource.flags &
897-
SeaFlags::kDisableExperimentalSeaWarning)) {
898-
is_experimental_warning_needed = true;
899-
}
900910
}
901911

902912
target
@@ -909,17 +919,17 @@ void Initialize(Local<Object> target,
909919
FIXED_ONE_BYTE_STRING(isolate, "isVfsEnabled"),
910920
Boolean::New(isolate, is_vfs_enabled))
911921
.Check();
912-
target
913-
->Set(context,
914-
FIXED_ONE_BYTE_STRING(isolate, "isExperimentalSeaWarningNeeded"),
915-
Boolean::New(isolate, is_experimental_warning_needed))
916-
.Check();
917922

923+
SetMethod(context,
924+
target,
925+
"isExperimentalSeaWarningNeeded",
926+
IsExperimentalSeaWarningNeeded);
918927
SetMethod(context, target, "getAsset", GetAsset);
919928
SetMethod(context, target, "getAssetKeys", GetAssetKeys);
920929
}
921930

922931
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
932+
registry->Register(IsExperimentalSeaWarningNeeded);
923933
registry->Register(GetAsset);
924934
registry->Register(GetAssetKeys);
925935
}

0 commit comments

Comments
 (0)