Skip to content

Commit 7435ccf

Browse files
committed
Fix v8-debug cleanup
1 parent e0f28d3 commit 7435ccf

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

v8-debug.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ var extend = require('util')._extend;
1010
var NODE_NEXT = require('./tools/NODE_NEXT');
1111
var nextTmpEventId = 1;
1212

13-
// Don't cache debugger module
14-
delete require.cache[module.id];
15-
1613
function InjectedScriptDir(link) {
1714
return require.resolve(__dirname + '/InjectedScript/' + link);
1815
};
@@ -117,10 +114,10 @@ function V8Debug() {
117114
this._wrapDebugCommandProcessor();
118115

119116
this.once('close', function() {
117+
this._disableWebkitProtocol();
120118
this._unwrapDebugCommandProcessor();
121119
this._unshareSecurityToken();
122120
this._unsetDebugEventListener();
123-
this.disableWebkitProtocol();
124121
});
125122
}
126123

@@ -147,22 +144,26 @@ V8Debug.prototype._unshareSecurityToken = function() {
147144
V8Debug.prototype._wrapDebugCommandProcessor = function() {
148145
var proto = this.get('DebugCommandProcessor.prototype');
149146
this._DebugCommandProcessor = proto;
150-
overrides.processDebugRequest_ = proto.processDebugRequest;
151-
extend(proto, overrides);
152-
overrides.extendedProcessDebugJSONRequestHandles_['disconnect'] = function(request, response) {
147+
148+
if (!proto.processDebugRequest_) {
149+
proto.processDebugRequest_ = proto.processDebugRequest;
150+
extend(proto, overrides);
151+
}
152+
153+
proto.extendedProcessDebugJSONRequestHandles_['disconnect'] = function(request, response) {
153154
this.emit('close');
154-
proto.processDebugJSONRequest(request);
155+
var proto = this._DebugCommandProcessor;
156+
proto.processDebugJSONRequest(request, response);
157+
return true;
155158
}.bind(this);
156159
};
157160

158161
V8Debug.prototype._unwrapDebugCommandProcessor = function() {
159-
var proto = this._DebugCommandProcessor;
160-
proto.processDebugRequest = proto.processDebugRequest_;
161-
delete proto.processDebugRequest_;
162-
delete proto.extendedProcessDebugJSONRequest_;
163-
delete proto.extendedProcessDebugJSONRequestHandles_;
164-
delete proto.extendedProcessDebugJSONRequestAsyncHandles_;
162+
var proto = this.get('DebugCommandProcessor.prototype');
165163
delete this._DebugCommandProcessor;
164+
165+
proto.extendedProcessDebugJSONRequestHandles_ = {};
166+
proto.extendedProcessDebugJSONRequestAsyncHandles_ = {};
166167
};
167168

168169
V8Debug.prototype.register =
@@ -339,11 +340,10 @@ V8Debug.prototype.enableWebkitProtocol = function() {
339340
}
340341
};
341342

342-
V8Debug.prototype.disableWebkitProtocol = function() {
343+
V8Debug.prototype._disableWebkitProtocol = function() {
343344
if (!this._webkitProtocolEnabled) return;
344345
this._webkitProtocolEnabled = false;
345-
346-
this.runInDebugContext('ToggleMirrorCache()');
346+
this.runInDebugContext('ToggleMirrorCache(true)');
347347
};
348348

349349
V8Debug.prototype.releaseObject =

0 commit comments

Comments
 (0)