Skip to content

Commit 453ca3b

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 9bd4cda commit 453ca3b

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
@@ -565,6 +565,25 @@ std::optional<SeaConfig> ParseSingleExecutableConfig(
565565
return std::nullopt;
566566
}
567567

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

0 commit comments

Comments
 (0)