You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We've recently discovered that isolated-vm can cause a main-thread deadlock when attempting to dispose of isolates. This appears to occur when a promise from the main isolate is pending and proxied into the to-be-disposed isolate. Given that it looks like you're no longer actively maintaining the project I'd be happy to contribute a fix if I could be pointed in the right direction.
Reproduction script:
const ivm = require('isolated-vm');
setInterval(() => { console.log("Event Loop is running"); }, 100); // Never logged.
const isolate = new ivm.Isolate();
const context = isolate.createContextSync();
context.global.setSync("getProm", () => new Promise(() => {}), { reference: true });
context.eval("getProm.applySync()");
context.release();
console.log(`Context released`);
isolate.dispose();
console.log(`Isolate disposed`); // Never logged
Further testing has caused me to realize I was entirely mistaken when thinking this was related to promises. In fact, it appears to be due to isolate disposal while there's a scheduled async task that interacts synchronously with the main isolate:
const ivm = require('isolated-vm');
setInterval(() => { console.log("Event Loop is running"); }, 100);
(async () => {
const isolate = new ivm.Isolate();
const context = isolate.createContextSync();
context.global.setSync("getProm", () => {}, { reference: true });
context.eval("getProm.applySync()"); // Awaiting here resolves the issue
context.release();
console.log(`Context for Isolate released`);
isolate.dispose();
console.log(`Isolate disposed`);
})();
Hi there!
We've recently discovered that isolated-vm can cause a main-thread deadlock when attempting to dispose of isolates. This appears to occur when a promise from the main isolate is pending and proxied into the to-be-disposed isolate. Given that it looks like you're no longer actively maintaining the project I'd be happy to contribute a fix if I could be pointed in the right direction.
Reproduction script:
Process sample:
The text was updated successfully, but these errors were encountered: