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
Conversation
This was caught as we adopted the promisified methods and noticed them not resolving in the renderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clean enough!
ae1cef9
to
1d08b8a
Compare
Release Notes Persisted
|
I was unable to backport this PR to "7-0-x" cleanly; |
I was unable to backport this PR to "8-x-y" cleanly; |
@MarshallOfSound has manually backported this PR to "8-x-y", please check out #20946 |
@MarshallOfSound has manually backported this PR to "7-0-x", please check out #20947 |
@MarshallOfSound has manually backported this PR to "7-1-x", please check out #20947 |
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>
… 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>
A common module
Bluebird
overrides thePromise
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