Skip to content

Commit

Permalink
fix(contextwrap): remove window and context while ContextWrap.destory
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyoukun committed Jul 23, 2018
1 parent ce7ff70 commit 36bbfe8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
12 changes: 6 additions & 6 deletions bin/proxy/http.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ module.exports = function(req, res) {
d.remove(res);

if (d.currentContext) {
d.currentContext.window.request = null;
d.currentContext.window.response = null;
d.currentContext.window.onerror = null;
d.currentContext.window = null;
}
if (d.currentContext.window) {
d.currentContext.window.request = null;
d.currentContext.window.response = null;
d.currentContext.window.onerror = null;
d.currentContext.window = null;
}

if (d.currentContext) {
d.currentContext.log = null;
d.currentContext = null;
}
Expand Down
19 changes: 17 additions & 2 deletions bin/tsw/runtime/ContextWrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,23 @@ class ContextWrap extends EventEmitter {
}

destroy() {
this._domain.remove(this._req);
this._domain.remove(this._rsp);

const d = this._domain;

d.remove(this._req);
d.remove(this._rsp);

if (d.currentContext) {
if (d.currentContext.window) {
d.currentContext.window.request = null;
d.currentContext.window.response = null;
d.currentContext.window.onerror = null;
d.currentContext.window = null;
}

d.currentContext.log = null;
d.currentContext = null;
}

this._domain = null;
this._req = null;
Expand Down

0 comments on commit 36bbfe8

Please sign in to comment.