Merge pull request +15998 from c9/node-debugger

Workaround for node 9  segfault
pull/483/head
Harutyun Amirjanyan 2018-02-28 19:33:01 +04:00 zatwierdzone przez GitHub
commit 39c4749d12
4 zmienionych plików z 36 dodań i 5 usunięć

Wyświetl plik

@ -78,7 +78,15 @@ function Debugger(options) {
self.disconnect(); self.disconnect();
}); });
ws.on("message", function incoming(data) { ws.on("message", function incoming(data) {
try {
var parsed = JSON.parse(data);
} catch (e) {
}
// console.log("<<" + data); // console.log("<<" + data);
// ignore for now since this is noisy, and is not used on the client
if (parsed && parsed.method == "Runtime.consoleAPICalled")
return;
broadcast(data); broadcast(data);
}); });
ws.on("error", function(e) { ws.on("error", function(e) {
@ -128,7 +136,7 @@ function Debugger(options) {
if (this.ws) if (this.ws)
this.ws.close(); this.ws.close();
if (this.v8Socket) if (this.v8Socket)
this.v8Socket.close(); this.v8Socket.destroy();
}; };
}).call(Debugger.prototype); }).call(Debugger.prototype);

Wyświetl plik

@ -50,7 +50,6 @@ var DevtoolsProtocol = module.exports = function(socket) {
// TODO add support for threads // TODO add support for threads
break; break;
case "Runtime.executionContextDestroyed": case "Runtime.executionContextDestroyed":
console.log(message.params);
this.detachDebugger(); this.detachDebugger();
break; break;
case "Debugger.resumed": case "Debugger.resumed":

Wyświetl plik

@ -26,15 +26,25 @@ var socketPath = process.env.HOME + "/.c9/chrome.sock";
if (IS_WINDOWS) if (IS_WINDOWS)
socketPath = "\\\\.\\pipe\\" + socketPath.replace(/\//g, "\\"); socketPath = "\\\\.\\pipe\\" + socketPath.replace(/\//g, "\\");
var force = process.argv.indexOf("--force") != -1;
console.log("Using socket", socketPath); console.log("Using socket", socketPath);
function checkServer(id) { function checkServer(id) {
var client = net.connect(socketPath, function() { var client = net.connect(socketPath, function() {
if (id) return; if (id) return;
if (!force) {
console.log("process already exists"); console.log("process already exists");
process.exit(0); process.exit(0);
}
else {
console.log("trying to replace existing process");
var strMsg = JSON.stringify({ $: "exit" });
client.write(strMsg + "\0");
}
}); });
client.on("data", function(data) { client.on("data", function(data) {
if (force)
return console.log("old pid" + data);
try { try {
var msg = JSON.parse(data.toString().slice(0, -1)); var msg = JSON.parse(data.toString().slice(0, -1));
} catch (e) {} } catch (e) {}
@ -52,6 +62,13 @@ function checkServer(id) {
process.exit(1); process.exit(1);
}); });
if (force) {
client.once("close", function() {
if (!server)
createServer();
});
}
} }
var $id = 0; var $id = 0;

Wyświetl plik

@ -80,7 +80,14 @@ define(function(require, exports, module) {
} }
var list = breakpoints.slice(0); var list = breakpoints.slice(0);
var retries = 0; if (list.length == 0) {
// node v9.5 segfaults when there are no breakpoints
list.push({
path: "_c9_node_segfault_workaround_",
line: 100,
enabled: true,
});
}
listBreakpoints(function handleBps(err, remoteBreakpoints) { listBreakpoints(function handleBps(err, remoteBreakpoints) {
if (err) return callback(err); if (err) return callback(err);