Skip to content

chore: remove EnvironmentOptions::experimental_fetch dependency#52028

Merged
jkleinsc merged 5 commits into
43-x-yfrom
trop/43-x-y-bp-chore-remove-environmentoptions-experimental_fetch-dependency-1781642684707
Jun 18, 2026
Merged

chore: remove EnvironmentOptions::experimental_fetch dependency#52028
jkleinsc merged 5 commits into
43-x-yfrom
trop/43-x-y-bp-chore-remove-environmentoptions-experimental_fetch-dependency-1781642684707

Conversation

@trop

@trop trop Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Backport of #51923

See that PR for details.

Notes: none

trop Bot and others added 4 commits June 16, 2026 20:44
Node.js removed the experimental_fetch option in nodejs/node#62759
since fetch is now unconditionally enabled. We had been patching the
field back in so that node_main.cc could read it and node_bindings.cc
could pass --no-experimental-fetch to renderer/worker processes.

Neither is necessary:

- In ELECTRON_RUN_AS_NODE mode, fetch is always available, so WASM
  streaming (which depends on Response) should always be set up.
- In renderer/worker processes, kNoBrowserGlobals already causes
  Node's PrincipalRealm::BootstrapRealm to skip
  internal/bootstrap/web/exposed-window-or-worker.js, which is where
  fetch/Request/Response/Headers/FormData are defined. Node's fetch
  globals were never being installed; Blink's win by default.

Drop the patch and the two call sites that depended on it.

Closes #51912

Co-authored-by: Felix Rieseberg <[email protected]>
SetIsolateUpForNode now unconditionally registers Node's WASM streaming
callback (nodejs/node#62759 dropped the experimental_fetch gate). With
kNoBrowserGlobals the JS half of that callback is never installed, so
WebAssembly.compileStreaming/instantiateStreaming would crash on
CHECK(\!impl.IsEmpty()) in node_wasm_web_api.cc.

Re-register Blink's handler via WasmResponseExtensions::Initialize after
CreateEnvironment in renderer and worker so Blink's implementation wins.

Also drop the now-redundant blink* global stash/restore: with
kNoBrowserGlobals Node neither installs nor deletes fetch/Response/etc,
so Blink's bindings are never disturbed and the round-trip through
blinkfetch was a no-op.

Add a spec asserting fetch/Headers/Request/Response/FormData stringify
to [native code] in a nodeIntegration renderer.

Co-authored-by: Felix Rieseberg <[email protected]>
- Resolve modify/delete on the fetch patch (delete wins; the
  experimental_fetch gate it added to environment.cc is no longer
  needed since WasmResponseExtensions::Initialize handles the
  callback restoration in Electron's renderer code).
- Revert the environment.cc index hash in
  api_delete_deprecated_fields_on_v8_isolate.patch now that the
  preceding patch is gone (verified with `e patches node`).
- Preserve Blink's EventSource around LoadEnvironment in renderer
  and worker: Node's setupEventsource() in pre_execution.js deletes
  globalThis.EventSource whenever --experimental-eventsource is not
  set, and unlike setupNavigator/setupWebStorage it does not check
  noBrowserGlobals first. The previous blink* stash covered this as
  a side effect; restore just EventSource explicitly in C++.
- Extend the [native code] spec assertion to cover EventSource.

Co-authored-by: Felix Rieseberg <[email protected]>
The C++ save/restore around LoadEnvironment was too late: preload
scripts run inside LoadEnvironment, after Node's setupEventsource()
has deleted globalThis.EventSource but before the C++ restore. This
broke 'preload has synchronous access to all eventual window APIs'.

Pass --experimental-eventsource for renderer/worker so Node's
setupEventsource() becomes a no-op and Blink's binding is never
deleted. Under kNoBrowserGlobals Node never installs its own undici
EventSource, so the flag's only effect is suppressing the delete.

Co-authored-by: Felix Rieseberg <[email protected]>
@trop
trop Bot requested a review from a team as a code owner June 16, 2026 20:44
@trop trop Bot added 43-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Jun 16, 2026
@dsanders11

Copy link
Copy Markdown
Member

/trop update-branch

…ions-experimental_fetch-dependency-1781642684707
@trop

trop Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

This branch has been updated with the latest changes from 43-x-y.

@electron-datadog

This comment has been minimized.

@jkleinsc
jkleinsc merged commit f395ac6 into 43-x-y Jun 18, 2026
122 of 124 checks passed
@jkleinsc
jkleinsc deleted the trop/43-x-y-bp-chore-remove-environmentoptions-experimental_fetch-dependency-1781642684707 branch June 18, 2026 19:12
@release-clerk

release-clerk Bot commented Jun 18, 2026

Copy link
Copy Markdown

No Release Notes

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

Labels

43-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants