Skip to content

Commit

Permalink
Issue #386 [Enhancement][WIP] Avoid proxying a proxy in tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
t2ym committed Oct 9, 2020
1 parent 9191368 commit 292ee44
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion demo-config/Tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const Traceable = (base) => class TraceableConfigBase extends base {
}
Object.assign(trace.proxy.this.handler, {
get: function(target, property, receiver) {
if (property === Symbol.for('isProxy')) {
return true;
}
if (((target === trace.proxy.this.target && ['trace', 'pre', 'post'].indexOf(property) < 0) || target !== trace.proxy.this.target) && target.hasOwnProperty(property)) {
if (trace.currentPlugin) {
let isProxy = false;
Expand All @@ -106,6 +109,9 @@ const Traceable = (base) => class TraceableConfigBase extends base {
isProxy = true;
}
}
if (target[Symbol.for('isProxy')]) {
isProxy = true;
}
let propertyName = trace.propertyName(name, property);
//console.log(`${proxy.currentPlugin.name} get ${propertyName}`);
traceLog[trace.currentPlugin.name] = traceLog[trace.currentPlugin.name] || new Set();
Expand All @@ -116,7 +122,7 @@ const Traceable = (base) => class TraceableConfigBase extends base {
let desc = Object.getOwnPropertyDescriptor(target, property);
if (desc && desc.configurable && desc.writable) {
let _target = (isProxy ? trace.proxy[name].target : target)[property];
if (_target instanceof Object) {
if (_target instanceof Object && !_target[Symbol.for('isProxy')]) {
if (trace.proxy[propertyName]) {
if (trace.proxy[propertyName].target === _target) {
_trace = trace.proxy[propertyName].proxy;
Expand Down

0 comments on commit 292ee44

Please sign in to comment.