The browser opens the debug link, and the command entered in the console does not return a value
'use strict'; let WebSocket = require('ws'); let ivm = require('isolated-vm');
/**
- IMPORTANT: Allowing untrusted users to access the v8 inspector will almost certainly result in a
- security vulnerability. Access to these endpoints should be restricted. */
// Launch an infinite loop in another thread let isolate = new ivm.Isolate({ inspector: true }); (async function() { let context = await isolate.createContext({ inspector: true }); const inspector = isolate.createInspectorSession(); inspector.dispatchProtocolMessage('{"id":1,"method":"Debugger.enable"}'); let script = await isolate.compileScript('console.log("hello world");debugger; ', { filename: 'aa.js' }); await script.run(context); console.log("释放"); inspector.dispose(); }()).catch(console.error);
// Create an inspector channel on port 10000 var port = 4396; let wss = new WebSocket.Server({port });
wss.on('connection', function(ws) { console.log("connection"); // Dispose inspector session on websocket disconnect let channel = isolate.createInspectorSession(); function dispose() { try { channel.dispose(); } catch (err) {} } ws.on('error', dispose); ws.on('close', dispose);
// Relay messages from frontend to backend
ws.on('message', function(message) {
console.log('<', message.toString())
try {
channel.dispatchProtocolMessage(String(message));
} catch (err) {
// This happens if inspector session was closed unexpectedly
ws.close();
}
});
// Relay messages from backend to frontend
function send(message) {
console.log('>', message.toString())
try {
ws.send(message);
} catch (err) {
dispose();
}
}
channel.onResponse = (callId, message) => send(message);
channel.onNotification = send;
});
console.log(Inspector: devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:${port});
Yeah I can confirm that it broke at some point. I'm working on an revamped version of isolated-vm but I don't expect to have a stable version within the next 4 months or so.
Waiting for your good news, I saw someone on the forum saying that using a version of chrome 126 could solve the problem, but I didn't find it.
等待你的好消息,我在论坛上看到有人说使用 chrome 126 的一个版本可以解决问题,但我没有找到。
you can try chrome version 110-120
Yeah I can confirm that it broke at some point. I'm working on an revamped version of isolated-vm but I don't expect to have a stable version within the next 4 months or so.
I couldn't connect to debugging when I pulled the latest version with the Chrome142.0.7444.60 browser. I can connect to ws normally using the ws testing tool