Skip to content

fix: read nodeIntegrationInWorker from per-frame WebPreferences#50122

Merged
MarshallOfSound merged 1 commit intomainfrom
sam/worker-node-integration-per-frame
Mar 9, 2026
Merged

fix: read nodeIntegrationInWorker from per-frame WebPreferences#50122
MarshallOfSound merged 1 commit intomainfrom
sam/worker-node-integration-per-frame

Conversation

@MarshallOfSound
Copy link
Copy Markdown
Member

Previously the renderer checked a process-wide command-line switch to decide whether to create a Node.js environment for dedicated workers. When a renderer process hosts multiple WebContents with different nodeIntegrationInWorker values (e.g. via window.open with overridden webPreferences in setWindowOpenHandler), all workers in the process used whichever value the first WebContents set on the command line — the override had no effect.

This plumbs the flag through blink's WorkerSettings at worker creation time, copying it from the initiating frame's WebPreferences. The check on the worker thread then reads the per-worker value. Nested workers inherit the flag from their parent worker via WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it is no longer consumed.

Notes: Fixed an issue where nodeIntegrationInWorker overrides in setWindowOpenHandler were not honored for child windows sharing a renderer process with their opener.

Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.
@MarshallOfSound MarshallOfSound added the semver/patch backwards-compatible bug fixes label Mar 8, 2026
@MarshallOfSound MarshallOfSound requested a review from a team as a code owner March 8, 2026 07:36
@MarshallOfSound MarshallOfSound added target/38-x-y PR should also be added to the "38-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. semver/patch backwards-compatible bug fixes labels Mar 8, 2026
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 8, 2026
}
}
}));

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.

nit: can you add snippet to check worker from parent has node integration in this case

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops missed this comment, will add in a follow up

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 9, 2026
@MarshallOfSound MarshallOfSound merged commit 603679c into main Mar 9, 2026
96 of 97 checks passed
@MarshallOfSound MarshallOfSound deleted the sam/worker-node-integration-per-frame branch March 9, 2026 07:50
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Mar 9, 2026

Release Notes Persisted

Fixed an issue where nodeIntegrationInWorker overrides in setWindowOpenHandler were not honored for child windows sharing a renderer process with their opener.

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 9, 2026

I was unable to backport this PR to "39-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot removed the target/39-x-y PR should also be added to the "39-x-y" branch. label Mar 9, 2026
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 9, 2026

I was unable to backport this PR to "38-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 9, 2026

I was unable to backport this PR to "40-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot added needs-manual-bp/39-x-y needs-manual-bp/38-x-y and removed target/38-x-y PR should also be added to the "38-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. labels Mar 9, 2026
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 9, 2026

I have automatically backported this PR to "41-x-y", please check out #50134

@trop trop bot added in-flight/41-x-y and removed target/41-x-y PR should also be added to the "41-x-y" branch. labels Mar 9, 2026
VerteDinde pushed a commit that referenced this pull request Mar 9, 2026
Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 9, 2026

@VerteDinde has manually backported this PR to "38-x-y", please check out #50163

@trop trop bot added in-flight/38-x-y merged/41-x-y PR was merged to the "41-x-y" branch. and removed needs-manual-bp/38-x-y in-flight/41-x-y labels Mar 9, 2026
VerteDinde added a commit that referenced this pull request Mar 10, 2026
* fix: read nodeIntegrationInWorker from per-frame WebPreferences (#50122)

Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.

* chore: update patches

---------

Co-authored-by: Samuel Attard <sam@electronjs.org>
@trop trop bot added merged/38-x-y PR was merged to the "38-x-y" branch. and removed in-flight/38-x-y labels Mar 10, 2026
VerteDinde pushed a commit that referenced this pull request Mar 24, 2026
Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.
VerteDinde pushed a commit that referenced this pull request Mar 24, 2026
Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 24, 2026

@VerteDinde has manually backported this PR to "40-x-y", please check out #50467

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 24, 2026

@VerteDinde has manually backported this PR to "39-x-y", please check out #50468

VerteDinde pushed a commit that referenced this pull request Mar 24, 2026
Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.
VerteDinde pushed a commit that referenced this pull request Mar 24, 2026
Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.
VerteDinde added a commit that referenced this pull request Mar 24, 2026
…) (#50467)

Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.

Co-authored-by: Samuel Attard <sam@electronjs.org>
@trop trop bot added merged/40-x-y PR was merged to the "40-x-y" branch. and removed in-flight/40-x-y labels Mar 24, 2026
VerteDinde added a commit that referenced this pull request Mar 24, 2026
…) (#50468)

* fix: read nodeIntegrationInWorker from per-frame WebPreferences (#50122)

Previously the renderer checked a process-wide command-line switch to
decide whether to create a Node.js environment for dedicated workers.
When a renderer process hosted multiple WebContents with different
nodeIntegrationInWorker values (e.g. via window.open with overridden
webPreferences in setWindowOpenHandler), all workers in the process
used whichever value the first WebContents set on the command line.

Instead, plumb the flag through blink's WorkerSettings at worker
creation time, copying it from the initiating frame's WebPreferences.
The check on the worker thread then reads the per-worker value. Nested
workers inherit the flag from their parent worker via
WorkerSettings::Copy.

The --node-integration-in-worker command-line switch is removed as it
is no longer consumed.

* fix: restore base/command_line.h include needed by SetUpWebAssemblyTrapHandler

The backported PR removed this include (matching main where
SetUpWebAssemblyTrapHandler was refactored), but on 39-x-y the function
still uses base::CommandLine.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

---------

Co-authored-by: Samuel Attard <sam@electronjs.org>
Co-authored-by: Claude <svc-devxp-claude@slack-corp.com>
@trop trop bot added merged/39-x-y PR was merged to the "39-x-y" branch. and removed in-flight/39-x-y labels Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants