Skip to content

Commit c2abafd

Browse files
committed
vfs: reject useVfs with useSnapshot, useCodeCache, or mainFormat module
Add SEA config validation to error when useVfs is enabled together with useSnapshot, useCodeCache, or mainFormat: "module", as these combinations are not supported.
1 parent 0abdb2f commit c2abafd

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

doc/api/vfs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,11 @@ file system:
753753

754754
When running as a Single Executable Application (SEA) with `"useVfs": true` in
755755
the SEA configuration, bundled assets are automatically mounted at `/sea`. No
756-
additional setup is required:
756+
additional setup is required.
757+
758+
`"useVfs"` cannot be used together with `"useSnapshot"`, `"useCodeCache"`, or
759+
`"mainFormat": "module"`. The SEA configuration parser will error if any of
760+
these combinations are detected.
757761

758762
```cjs
759763
// In your SEA entry script

src/node_sea.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,25 @@ std::optional<SeaConfig> ParseSingleExecutableConfig(
570570
return std::nullopt;
571571
}
572572

573+
if (static_cast<bool>(result.flags & SeaFlags::kEnableVfs)) {
574+
if (static_cast<bool>(result.flags & SeaFlags::kUseSnapshot)) {
575+
FPrintF(stderr,
576+
"\"useVfs\" is not supported when \"useSnapshot\" is true\n");
577+
return std::nullopt;
578+
}
579+
if (static_cast<bool>(result.flags & SeaFlags::kUseCodeCache)) {
580+
FPrintF(stderr,
581+
"\"useVfs\" is not supported when \"useCodeCache\" is true\n");
582+
return std::nullopt;
583+
}
584+
if (result.main_format == ModuleFormat::kModule) {
585+
FPrintF(stderr,
586+
"\"useVfs\" is not supported when "
587+
"\"mainFormat\" is \"module\"\n");
588+
return std::nullopt;
589+
}
590+
}
591+
573592
if (result.main_path.empty()) {
574593
FPrintF(stderr,
575594
"\"main\" field of %s is not a non-empty string\n",

0 commit comments

Comments
 (0)