Description
Current protocol bases on seq
, request_seq
counters.
Pseudo code. Send backtrace
command:
debug_connection.request({
type: 'command',
command: 'backtrace',
seq: 5,
attributes: {...}
}, function(res) {
// res.request_seq == 5
processResponse(res);
});
Ok. It works fine.
What about Alice and Bob?
Alice tries to debug app and she pauses in random place of code. Her seq
couter is 4
(Alice.seq=4
).
She sends a backtrace
command and waits for response with request_seq=4
.
In this moment Bob also sends request to debugger. He sends lookup
request with Bob.seq=4
.
And "WOW! So fast lookup!" - thinks Bob, starts to parse response... "But wait! WHAT!"
res = {
request_seq: 4,
command: 'backtrace'
}
"It's not for my request!"
From _debug_agent:
function Agent() {
net.Server.call(this, this.onConnection);
this.first = true;
this.binding = process._debugAPI;
var self = this;
this.binding.onmessage = function(msg) {
self.clients.forEach(function(client) {
client.send({}, msg);
});
};
this.clients = [];
assert(this.binding, 'Debugger agent running without bindings!');
}
Are you see here a problem? =)
What I think about this:
Multi clients is a cool feature for debugger, but it over complicates the protocol realisation, and I do not know a situation where we need two or more debugger clients.
Is there a main discussion about new debugger?
I'm ready to work on some issues after discussion. Some other is out of my competence at this time.
Some other issues:
#781
nodejs/node-v0.x-archive#9156