Skip to content

sea: mount vfsArchive at layer 0 and in workers - #66614

Open
pipobscure wants to merge 1 commit into
nodejs:mainfrom
pipobscure:vfs-sea-workers
Open

pipobscure wants to merge 1 commit into
nodejs:mainfrom
pipobscure:vfs-sea-workers

Conversation

@pipobscure

Copy link
Copy Markdown
Contributor

A single executable application built with "vfsArchive" mounted its archive at the next free layer, like any file system a program mounts itself, and only in the main thread. A worker had no mount at all, so a path into the archive, such as the main script's __filename, could not be loaded there.

Mount the archive at the layer reserved for --vfs-load instead, so it is at the same mount point in every thread, and mount it in each worker as well, with the main script placed at its root just as in the main thread. The worker reads the main script through a new getMainCode() binding, since no main script is handed to it. Unlike the --vfs-load source, the archive needs no provider that a preload could register, so its mount in a worker is not deferred past --import.

Since the archive takes that mount point, reject --vfs-load in such an executable, whether it comes from "execArgv", from --node-options or from the execArgv of a worker.

Also fix the example in vfs.md, which showed a file system a program mounts itself at layer 0, the layer reserved for these mounts.

AI assistance was used. Every line was inspected by me personally. I also ran the tests under Linux & Windows.

A single executable application built with "vfsArchive" mounted its
archive at the next free layer, like any file system a program mounts
itself, and only in the main thread. A worker had no mount at all, so
a path into the archive, such as the main script's __filename, could
not be loaded there.

Mount the archive at the layer reserved for --vfs-load instead, so it
is at the same mount point in every thread, and mount it in each
worker as well, with the main script placed at its root just as in
the main thread. The worker reads the main script through a new
getMainCode() binding, since no main script is handed to it. Unlike
the --vfs-load source, the archive needs no provider that a preload
could register, so its mount in a worker is not deferred past
--import.

Since the archive takes that mount point, reject --vfs-load alongside
it: --build-sea refuses it in "execArgv", and the executable refuses it
at startup when it comes from --node-options or from the execArgv of a
worker.

Also fix the example in vfs.md, which showed a file system a program
mounts itself at layer 0, the layer reserved for these mounts.

Signed-off-by: Philipp Dunkel <pip@pipobscure.com>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/config
  • @nodejs/single-executable

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Oct 8, 2026
@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.20290% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.45%. Comparing base (f9defa6) to head (a42d7dd).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/node_sea.cc 86.36% 0 Missing and 3 partials ⚠️
src/node_options.cc 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66614      +/-   ##
==========================================
+ Coverage   90.43%   90.45%   +0.01%     
==========================================
  Files         791      791              
  Lines      276563   276612      +49     
  Branches    53115    53121       +6     
==========================================
+ Hits       250117   250214      +97     
+ Misses      16850    16792      -58     
- Partials     9596     9606      +10     
Files with missing lines Coverage Δ
lib/internal/main/embedding.js 91.80% <100.00%> (-0.09%) ⬇️
lib/internal/main/worker_thread.js 95.07% <100.00%> (+0.04%) ⬆️
lib/internal/vfs/sea.js 100.00% <100.00%> (ø)
src/node_sea.h 100.00% <ø> (ø)
src/node_options.cc 81.69% <80.00%> (-0.01%) ⬇️
src/node_sea.cc 87.87% <86.36%> (-0.01%) ⬇️

... and 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pipobscure

Copy link
Copy Markdown
Contributor Author

@mcollina @trivikr @jasnell could I get a review and CI start from one of you by chance. Thanks

@jasnell jasnell added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 9, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 9, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Oct 10, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 10, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@pipobscure

Copy link
Copy Markdown
Contributor Author

Can someone please check CI for this. There are 2 failure that are likely just CI croaking under strain, but if there’s something to fix I want to know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants