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

ReactDefaultPerf.printWasted() doesn't work #5548

Closed
Daniel15 opened this issue Nov 25, 2015 · 16 comments · Fixed by #6516
Closed

ReactDefaultPerf.printWasted() doesn't work #5548

Daniel15 opened this issue Nov 25, 2015 · 16 comments · Fixed by #6516

Comments

@Daniel15
Copy link
Member

Calling ReactDefaultPerf.printWasted() results in:

Uncaught TypeError: Cannot read property 'forEach' of undefined
writes.(anonymous function).forEach @ ReactDefaultPerfAnalysis.js:195
Object.keys.forEach @ ReactDefaultPerfAnalysis.js:192
getUnchangedComponents @ ReactDefaultPerfAnalysis.js:191
getInclusiveSummary @ ReactDefaultPerfAnalysis.js:139
ReactDefaultPerf.getMeasurementsSummaryMap @ ReactDefaultPerf.js:118
ReactDefaultPerf.printWasted @ ReactDefaultPerf.js:133

(this is on a page internally at Facebook so I assume it's a fairly recent React version)

@jimfb
Copy link
Contributor

jimfb commented Jan 12, 2016

@Daniel15 Are you still experiencing this issue internally? If so, can you create an internal task with details and repro steps? Assign to the oncall, cc the React team.

Our internal configuration is a bit different, and we don't want to discuss internal code/details/configurations on github. I'm going to close this out, and we can help you debug using internal tools if you're still running into problems.

@jimfb jimfb closed this as completed Jan 12, 2016
@lostfictions
Copy link

Small note for anyone experiencing a similar error message who arrived here by Googling: I got bit by this because I updated react and react-dom without updating react-addons-perf at the same time.

@sverrejoh
Copy link
Contributor

I'm getting this issue after upgrading to react 15.0.1. All my React packages (including perf) is 15.0.1. printExclusive() etc. works, but printWasted gives the exception shown above.

@gaearon
Copy link
Collaborator

gaearon commented Apr 10, 2016

@sverrejoh Are you running ReactPerf.start() before using it?

@sverrejoh
Copy link
Contributor

Yes. ReactPerf.start(), ReactPerf.stop() and the rest of the Perf API works, for example ReactPerf.printExclusive(), but not ReactPerf.printWasted().

I changed over to my 0.14.7 branch, and there everything works like it should, and I double checked that both ReactPerf and React was on 15.0.1.

image

I can dig around a bit more if this isn't anything known.

@gaearon gaearon reopened this Apr 10, 2016
@gaearon
Copy link
Collaborator

gaearon commented Apr 10, 2016

Let’s reopen until we hear more.

@Danita
Copy link

Danita commented Apr 14, 2016

I had it working for a few minutes and then it started failing without me doing anything strange.

@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

@Danita

Thanks for the info, do you also have the same stack trace and error message as the first post?

@Danita
Copy link

Danita commented Apr 14, 2016

Yes. I was exposing the Perf object as window.Perf. I tried again exposing it as window.P and P.printWasted() it's working again. Puzzling.

I'm using the full 15.0.1 ecosystem, on Babel 6, Webpack and Webpack dev server, testing on Chrome.

@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

Any chance you have a public project where you can more or less consistently reproduce this?

@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

Technically this means there was a write for which there was no hierarchy record. This code is super fragile so it’s hard to pin it down without having a specific component hierarchy that happens to cause this.

@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

If someone wants to spend some effort tracking it down, I would recommend:

  1. Add

    if (!measurement.hierarchy[id]) {
      console.log('missing hierarchy for', id)
    }

    just before this line in node_modules/react/lib/ReactDefaultPerfAnalysis.js.

  2. Add

    console.log('write for id', id, 'with args', fnName, args)

    just before this line in node_modules/react/lib/ReactDefaultPerf.js.

Then please share the relevant write for id logs that correspond to the ID you see in the missing hierarchy for message.

@Danita
Copy link

Danita commented Apr 14, 2016

@gaearon Thanks Dan, I'll try setting up that to see if I can help. Unfortunately I cannot share my project right now because of client terms.

@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

@Danita Yeah, I thought this might be the case. Thanks for taking the time to investigate.

@Danita
Copy link

Danita commented Apr 14, 2016

@gaearon OK I added the lines and I managed to also reproduce the error. Here you can find the console log.

FYI, my app is a SPA, I captured this on a route where I have a long list of items that can be filtered by certain criteria and doing Perf.start() before filtering and Perf.stop() Perf.printWasted() after some of those items were removed because of the filtering.

@gaearon
Copy link
Collaborator

gaearon commented Apr 14, 2016

Thank you, this is very helpful! I’ll dig into it and see if I can repro this given the new info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants