Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find callsites that would call toString() if we pass attributes through #10416

Merged
merged 2 commits into from
Aug 11, 2017

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Aug 9, 2017

The downside of merging #10385 is that we don’t know if we have internal callsites that would break because of toString once we start passing attributes through. This is not a problem in open source where we’ve had a warning for a long time.

I propose we add this warning now, and let it live for a few days. Then look at the top callsites, and how many there are (and if they are benign or if calling toString could cause issues).

@gaearon gaearon changed the title Find callsites that would call toString() if pass attributes through Find callsites that would call toString() if we pass attributes through Aug 9, 2017
@gaearon
Copy link
Collaborator Author

gaearon commented Aug 9, 2017

I didn’t add a test but I verified it works in the Babel standalone example.

screen shot 2017-08-09 at 01 37 09

Note the intention is to not show this warning but only log it internally.
We'll remove it after we get a sense of whether #10385 is dangerous or not.

@flarnie
Copy link
Contributor

flarnie commented Aug 9, 2017

I'm curious whether we want to try and get this merged/synced this week? @spicyj @sebmarkbage
Seems like the only risk is blocking further beta releases until we make a decision and either remove or keep this warning. ?

@gaearon
Copy link
Collaborator Author

gaearon commented Aug 9, 2017

Even for open source releases leaving it in isn't a big deal because we already warn about unknown attributes (so people who read warnings don't have them).

@sophiebits
Copy link
Contributor

I guess we don't think arrays are problematic? Or would we not pass them through?

@nhunzaker
Copy link
Contributor

@sebmarkbage
Copy link
Collaborator

sebmarkbage commented Aug 9, 2017

This isn't finding things that we used to call toString on but no longer do. The built-in toString just goes through valueOf so sometimes only valueOf is overridden to cover both.

E.g. This isn't detected as a custom toString.

var x = {valueOf(){ return 123; }}

@nhunzaker
Copy link
Contributor

@sebmarkbage Ah man. I didn't think of valueOf. Should we do a similar check in #10385 for that as well?

@flarnie
Copy link
Contributor

flarnie commented Aug 10, 2017

It sounds like the next steps are:

  1. update this to remove the !Array.isArray(value) && value.toString !== Object.prototype.toString checks
  2. land it and sync to Facebook
  3. get data on how widespread our issues might be with unknown props, and clean up any problems
  4. Land the attribute thing without the whitelist but toString all objects, not using a complex heuristic

I think we should consider continuing to work on it for 17.0, since steps 1-3 will require some time. I could be wrong, but I'd rather take the time to test this internally before releasing the change.

@flarnie
Copy link
Contributor

flarnie commented Aug 11, 2017

*that said, I'll try to take this over and get it in anyway.

fixing this as per Sebastian's feedback, because we want to find all
objects and not just ones with 'toString' defined. Because there may be
other corner cases and issues that are revealed.
@flarnie
Copy link
Contributor

flarnie commented Aug 11, 2017

Already landed this at FB using a work-around to do it quickly, and we are trying to collect the data we need to do the fixes. I'm still not sure we will get this process done in time for 16.0.

@nhunzaker
Copy link
Contributor

@flarnie That sounds good. While I'm excited for this to land, I don't want my enthusiasm to pressure a decision. I'll be ready to add attributes back to the whitelist in #10385 if need be.

@flarnie
Copy link
Contributor

flarnie commented Aug 11, 2017

Thanks @nhunzaker - really really really happy to be collaborating with you. :)

@flarnie
Copy link
Contributor

flarnie commented Aug 11, 2017

Did the same manual test as @gaearon and it still fires as expected, although as he said, we don't really want to release this, but to add it for our own logging purposes.

screen shot 2017-08-11 at 11 02 46 am

@flarnie
Copy link
Contributor

flarnie commented Aug 11, 2017

Landing this for now, but we are still working on this:

get data on how widespread our issues might be with unknown props, and clean up any problems

Hopefully will have an update by Monday or Tuesday about how this goes and what we can do next.

@flarnie flarnie merged commit 58e6ede into facebook:master Aug 11, 2017
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.

6 participants