-
Notifications
You must be signed in to change notification settings - Fork 15k
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
vm module timeout option not working in main process #26560
Comments
Turns out it does work in a Worker Thread const { Worker, isMainThread } = require('worker_threads');
if (isMainThread) {
console.log('spawnin');
new Worker(__filename);
} else {
console.log('runnin');
try {
require('vm').runInNewContext('while (true);', {}, { timeout: 1 });
} catch (err) {
console.error(err);
}
console.log('stoppin');
}
I'm doing everything in a worker thread far away from the main process anyway. It's still a bug that the timeout does not work directly in the main process, but it doesn't concern me anymore. |
Thanks for reporting this and for including a testcase! Also, I like the idea of a "known differences" document but it's off-topic for this ticket. Could you file a separate ticket for that so that it can be tracked separately?
Looks like this test has been disabled since we first started running Node.js's test suite in our CI back in 1d06f67. At that time about 10% of the tests were failing. So this is a known issue in the sense that it's on the exclude list; but since it was one out of hundreds, I don't know if this one has had any specific discussion. |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment! |
Turns out The vm-timeout test was re-added here 5e1fbc9#diff-92a1788fffc3fc1f46ede1243c9ba69c6043c09f29bca54aa145b389836c7ff1L144 I don't know when exactly this was fixed, but 🥳 |
Preflight Checklist
Issue Details
I must assume this is a known issue, since the tests are disabled
electron/script/node-disabled-tests.json
Line 151 in e017d87
but I haven't found a mention in the issues. I also cannot find a list of differences between Electron and Node.js. Maybe this would be a great addition? E.g. the use of BoringSSL and all other things that are known to be different and potentially breaking when relying on Node.js compatibility. E.g. similar to this https://www.electronjs.org/docs/development/electron-vs-nwjs but "Differences between Node.js and Electron's Node.js fork".
Anyway, this is about the vm module:
Expected Behavior
I expect
runInNewContext
stimeout
option of the vm module to be respected.Actual Behavior
It never times out.
To Reproduce
Electron:
Node.js:
Additional Information
Originally reported to the vm2 module patriksimek/vm2#307
The comments might help tracing this down patriksimek/vm2#307 (comment)
This is explicitly about the main process. I don't care about vm being removed from the renderer #26087
The text was updated successfully, but these errors were encountered: