Skip to content

Conversation

@sbward
Copy link
Contributor

@sbward sbward commented Mar 4, 2018

Related to #568

Sometimes a Function Proxy gets inspected by getCustomFunctionDetails(), which breaks because Function.prototype.toString doesn't always work with Proxy objects.

This patch simply catches the TypeError and allows vue-devtools to continue rendering the Component details even if it contains funky Function Proxies. Currently if this occurs the Component detail view doesn't show, which leaves developers stuck tracking down the cause of the issue without the help of vue-devtools. This patch will at least allow the Component details to render, but the Function Proxy in question will not show argument details.

There might be a way to continue rendering the arguments for certain Function Proxies but I don't think it would be completely general.

Copy link
Member

@michalsnik michalsnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing and working on this @sbward.

I confirmed it, and the following code:

function sum(a, b) {
  return a + b;
}

const handler = {
  apply: function(target, thisArg, argumentsList) {
    console.log(`Calculate sum: ${argumentsList}`);
    return argumentsList[0] + argumentsList[1];
  }
};

const proxy1 = new Proxy(sum, handler);

Indeed produces an error:

// typeof proxy1 -> function
// Function.prototype.toString.call(proxy1) -> Function.prototype.toString requires that 'this' be a Function

I also don't see any other way of detecting if it's a proxy or not, so LGTM :)

@michalsnik michalsnik requested a review from Akryum March 11, 2018 11:30
@Akryum Akryum added this to the v4.1.4 milestone Mar 11, 2018
@Akryum Akryum self-assigned this Mar 11, 2018
@Akryum Akryum merged commit be053bb into vuejs:master Mar 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants