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
[Bug]: proxyquire can't load modules after window.open method is called #37404
Comments
@zcbenz , @deepak1556 , could you please help analyzing this issue? |
To simplify the issue, following code is enough to trigger the bug: const vm = require('node:vm');
const context = { x: 2 };
vm.createContext(context);
window.open('');
vm.runInContext('x += 40; var y = 17;', context); This bug is still mysterious to me though. |
@kyrylo-hrechykhin @zcbenz Blink assumes that all The stacktrace is as follows:
which confirms the above. Personally, I don't think there's really a good path forward here beyond to avoid tripping that faulty assumption in Blink (since patching whac-a-mole would not be a smart choice here), but i'm happy to be proven wrong! |
Getting the same error with just a simple require:
it is a major roadblock for us to upgrade to Electron 23+ |
@gpetrov Edit: ah, i see the new aspect of this bug! I'll take a look this week - tracked it to 75d2caf |
@gpetrov a repro from you with dockerode would still be helpful! Some preliminary research shows this seems to affect vm scripts run after |
@codebytere will do my best to isolate the case. We do use |
@codebytere definately window.open related. When I have that the next require fails directly. Also got a crash in during the testing, not sure if it is related: https://sentry.wappler.io/share/issue/be27b0431aa54a5c8f8f668e72776458/ |
@codebytere still happens in 23.2.1 - any news about merging the fix? |
Jitsi problem is also related, we have similar iframe contexts that the error occur. Will the solution also fix those iframe problems @codebytere |
what happen to the fix? @codebytere and @zcbenz - the problem still persist in the latest Electron 23, 24 and 25 |
@codebytere - finally I was able to isolate our use case for this bug! It was when creating dynamically iframes in the global scope! and those have full url as src and not about:blank. So this code causes also the error: <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<title>Hello World!</title>
<script>
function runTest() {
console.log('START runTest')
window.jQuery = window.$ = require('jquery');
}
</script>
</head>
<body>
<h1>Hello World!</h1>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
<button onclick="runTest()">Run Test</button>
<!-- You can also require other files to run in this process -->
<script src="./renderer.js"></script>
<script>
//After creating dynamically iframe at the end of the body - all subsequential requires as this on in runTest() fail
var iframe = document.createElement('iframe');
iframe.src = 'iframe.html';
document.body.appendChild(iframe);
</script>
</body>
</html> Is this the same problem? |
@gpetrov do you have a more reproducible sample than that? given it doesn't run as-is i want to make sure i'm checking the right thing against the fix! |
@codebytere sure here is my full sample: just extract, do npm install, run it, press the runTest button and check the devtools |
@gpetrov great news: Same bug - no error on my fix branch |
@codebytere that is awesome! With the same sample on 25.1.0 i get: So hope your fix gets merged quickly, as we need it desperately! |
This issue seems to be consist of 2 separate bugs:
|
This issue still leaves unfixed since no release version contains the fix |
@codebytere please reopen the issue as it isn't fixed yet. Or do we need to post a new issue? |
I ran into what looks like this issue in Electron 26, but seems fixed in 27. (And hello again @gpetrov, seems we have all the same bugs!) |
Preflight Checklist
Electron Version
23.0.0
What operating system are you using?
Windows
Operating System Version
Windows 11, Version22H2, OS Build 22621.1265
What arch are you using?
x64
Last Known Working Electron version
22.3.1
Expected Behavior
proxyquire should load modules as it does with electron version 22.3.1.
Actual Behavior
Attempt to use proxyquire in tests with electron of version 23 an higher leads to the following error message:
Testcase Gist URL
https://gist.github.com/kyrylo-hrechykhin/f0afe7c469145c51d4df39fbea97ec95
Additional Information
Workarounds:
Details:
Issue is probably caused by node version upgrade in electron 23. But as it worked in electron 22, I consider it as a regression. I also could not reproduce this issue in non-electron environment.
Run testcase gist locally:
Run the following commands in the folder where all the files specified in the attached gist.
Please upgrade/downgrade electron versions to see actual/expected results.
The text was updated successfully, but these errors were encountered: