Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: capture the promise global to avoid userland mutation #20925

Merged
merged 1 commit into from Nov 4, 2019

Conversation

MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Nov 2, 2019

A common module Bluebird overrides the Promise global with a non A+ implementation that doesn't support thennables (Promise.resolve({ then: () => Promise.resolve(123) })).

This modifies Electrons code to make it impossible for us to rely on the global, instead we cache the global at runtime in the capturedGlobals object that is auto-injected by webpack where it is used.

There is also an eslint rule to prevent accidental re-introduction of this issue.

This is kinda similar to node's primordials but doesn't strip prototypes and deep clone, it just retains a reference to the original constructor.

Notes: Fixed issue where proxied remote promises might not resolve if Bluebird was installed in the renderer

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Nov 2, 2019
@MarshallOfSound
Copy link
Member Author

This was caught as we adopted the promisified methods and noticed them not resolving in the renderer

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Nov 3, 2019
Copy link
Member

@felixrieseberg felixrieseberg left a comment

Choose a reason for hiding this comment

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

Looks clean enough!

lib/renderer/api/remote.js Outdated Show resolved Hide resolved
@MarshallOfSound MarshallOfSound merged commit 2678218 into master Nov 4, 2019
@release-clerk
Copy link

release-clerk bot commented Nov 4, 2019

Release Notes Persisted

Fixed issue where proxied remote promises might not resolve if Bluebird was installed in the renderer

@MarshallOfSound MarshallOfSound deleted the capture-the-promise-global branch November 4, 2019 19:16
@trop
Copy link
Contributor

trop bot commented Nov 4, 2019

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

@trop
Copy link
Contributor

trop bot commented Nov 4, 2019

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

@trop
Copy link
Contributor

trop bot commented Nov 4, 2019

@MarshallOfSound has manually backported this PR to "8-x-y", please check out #20946

@trop
Copy link
Contributor

trop bot commented Nov 4, 2019

@MarshallOfSound has manually backported this PR to "7-0-x", please check out #20947

@trop
Copy link
Contributor

trop bot commented Nov 4, 2019

@MarshallOfSound has manually backported this PR to "7-1-x", please check out #20947

@trop trop bot added the in-flight/7-1-x label Nov 4, 2019
@sofianguy sofianguy added this to Fixed in 7.1.0 in 7.2.x Nov 6, 2019
@sofianguy sofianguy added this to Fixed in 8.0.0-beta.3 in 8.2.x Nov 21, 2019
andersk added a commit to andersk/electron-remote that referenced this pull request Mar 1, 2022
This an equivalent of electron/electron#20925.
It’s needed for us to pass the test suite when we’re actually testing
this module instead of Electron’s builtin remote.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
nornagon pushed a commit to electron/remote that referenced this pull request Mar 15, 2022
… 14, 15, 16, and 17 (#113)

* fix: Capture Promise global to avoid userland mutation

This an equivalent of electron/electron#20925.
It’s needed for us to pass the test suite when we’re actually testing
this module instead of Electron’s builtin remote.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* test: Add missing semicolon

Semicolons are optional in JavaScript, except when they aren’t.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* test: Test this module, not the builtin electron.remote

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* test: Use enable() instead of enableRemoteModule: true

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* test: Cast remote-get-global message for Electron ≥ 14

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* test: Skip error cause test for Electron ≥ 14

Signed-off-by: Anders Kaseorg <andersk@mit.edu>

* ci: Test with Electron 14, 15, 16, and 17

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
7.2.x
Fixed in 7.1.0
8.2.x
Fixed in 8.0.0-beta.3
Development

Successfully merging this pull request may close these issues.

None yet

4 participants