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: window.open
causing occasional Node.js crashes
#38754
Conversation
1fe12a6
to
9c86258
Compare
I am a bit confused by this statement, I am just going by the test case here, looks like electron/shell/renderer/electron_renderer_client.cc Lines 88 to 93 in 678d1aa
In that case, wouldn't a simpler fix be to not create the node environment if there is one already existing for a given render frame ? I find it a bit weird that we are retrieving isolate data from a context rather than from the environment. |
f17e662
to
5bdf6e8
Compare
a62083e
to
7ed3d08
Compare
0aa9c0d
to
57099fa
Compare
c5dc455
to
84004cb
Compare
I think #37404 and #36858 are essentially different bugs and should be fixed separately. #37404 consists of 2 bugs:
#36858 is a race condition that, when closing window one node env marks the isolate as disallow_js during cleanup, while another env node still runs code in the same isolate, which triggers an assertion. |
@zcbenz here is what we found while debugging this PR, Today Electron allows creation of multiple
Apart from the above two we allow creating one On the contrary, in Node.js at a given time only a single Given the current implementation in Electron leads to the race situation where destructing one environment can disallow JS that triggers #36858 and also in cases where Tl:dr; I think this PR is intended to address |
If we share the Node Environment across multiple contexts, will modules only load in the first context? |
Release Notes Persisted
|
I was unable to backport this PR to "24-x-y" cleanly; |
I was unable to backport this PR to "26-x-y" cleanly; |
I was unable to backport this PR to "25-x-y" cleanly; |
@codebytere what is the status here? Seems not really merged with the main - are there still any issues? Like with the Appveyor? |
So is this in 26.x but not in 25.x or earlier? |
Is there any plan to backport this fix to the previous version? 26.x is still not stable and the version below 25 still crashes |
Well the fix is still not merged fully, we all hope that @codebytere manage to merge it soon to all supported versions as it is desperately needed |
@codebytere any news on this merge as it seems it isn't even included in the final electron 26. We really desperately need it and can't move on electron 23+ because of this issue... |
@zcbenz could you please assist in merging this? |
@codebytere could you please continue working on this issue as it isn't merged yet. It is essential to get this fixed so we can move from Electron 22 to newer versions. |
* fix: window.open causing occasional Node.js crashes * chore: always free isolate data * chore: clear pending ticks in worker thread * fix: UAF crash when creating WebWorkerObserver --------- Co-authored-by: deepak1556 <hop2deep@gmail.com>
Thanks to @deepak1556 and the other participants in this thread for shedding light on some obscure issues that have been plaguing my app since the beginning. Since the app is strictly desktop only, and quite a heavy user of Node fs APIs, I have Pre-Electron 13, the issues mostly surfaced as strange Node failures and hangs after a window reload, especially around child windows and iframes. But they could mostly be worked around by fiddling with the (now deprecated) After finally managing to refactor away Therefore, I would like to ask if you can think of any other workarounds except avoiding use of |
Description of Change
Closes #37404.
Closes #36858.
Refs #35999
Fixes an issue where
window.open
can interfere with various aspects of Node.js functionality.Node.js stores
IsolateData
internally on theEnvironment
as a member, whereas Blink stores it usingV8PerIsolateData
. This creates a situation where, in the renderer process, a previousIsolateData
could be used for a newv8::Context
, which then created a schism in the intended connection between the two. This would, for example, be a problem when using the vm module, becauseContextifyScript::InstanceOf
would try to check this condition from theIsolateData
which was mismatched. We fix this by adding a new embedder index and associating it with the context, so that we ensure theIsolateData
Node.js is using is correctly associated with the currentV8::Context
.Checklist
npm test
passesRelease Notes
Notes: Fixed an issue where
window.open
can interfere with various aspects of Node.js functionality.