-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Did not expect componentDidMount timer to start while render timer is still in progress for another instance #7349
Comments
This is on my list, I’ll look at fixing it this week. To be clear, this warning itself is not valuable to you, you should look for an earlier error in your code instead. This is just a symptom; the root cause is as you described:
An earlier error occurred in your app, so scroll the console up and look at the original error, not this warning, or |
@gaearon Scrolling back there is no related error being logged, but React does choke on it, which is both strange and annoying. |
This probably means you are using a Promise polyfill that swallows errors. Could that be the case? |
@gaearon, that might be possible, not sure how to fix that though, I do get occasional errors from |
|
I got the same Error today. As soon as I subscribe to a reducer form 2 different components loaded simultaneously on screen and trying to access the same reducer it throws the error. I am using Redux. |
@AdityaAthavale interesting, it crossed my mind that it was because of multiple dispatches at the same time, but through nothing of it. This might be one of the causes |
I just got this error while trying to implement dimensional charts using crossfilter.js. I believe one of my crossfilter operations is causing the choke..
|
I just got this by having a faulty function |
As I said above this warning has zero effect on your errors. I will remove it soon but for now it is absolutely irrelevant and you can ignore it. If you don't see the real error, this is a problem with your setup. Adding another comment in this thread about the type of error that caused it will not help us. It will occur for any error, so there is no need to describe many different ways you could cause an error in JavaScript. This is not specific to React or Redux in any way. What will help us is if you reproduce this warning without an error before it, and share that code. Trim down your project, publish the result and instructions to reproduce, and send a link here. Then I can take a look at why your error is being swallowed. But again, if errors are swallowed in your setup, us removing this warning won't fix your problem. Your errors will keep getting silently swallowed because there is something else hiding them, and we don't know why. So please only add new comments if you have a project showing how an error gets swallowed. Thanks! |
@gaearon sorry for posting without more info. I posted it because I was getting this warning without an prior errors being thrown. The issue was that I was importing a function from another file, and then function had an artifact reference to a |
Hi guys I had a similar error in a browser console. And due of some debugging I found uncatched exception in my componentWillMount/componentWillUnmount functions. That exception did not traced to the browser console. componentWillMount(){
try {
doSomeStuff()
} catch (e) {
console.error(e)
}
} So I guess you should try to wrap a code inside component's lifecycle functions with try/catch UPD |
No, adding your own try/catch is not the recommended solution, it's working around the real problem (something swallows your exceptions). It would be great if you could share your project. I could take a look at why your exceptions are being swallowed. |
@gaearon Can you explain what the error tries to describe? Even if it is not relevant for the original issue. "Did not expect componentDidMount timer to start" Who/which function/component did not expect it? Does every element get a timer? or is there a central timer that starts? "while render timer is still in progress for another instance" Which other instance? What does that other instance have to do with this instance? Is the error wrongly outputted (a.ka. not the real error) because a previous error was swallowed, and if yes then why is it outputted or how? These might be very specific questions to answer, but the fact is that people are coming here to solve this mysterious error, that only shows up in specific cases. ( the intended, but also unindended cases) We have no way to distinguish between the so called I think letting people post their specific circumstances here is more helpfull to get a grip on it, than saying that posting is useless or irrelevant. Or that it occurs for any error is simply not true. |
@gaearon of cause try/catch only for detecting a problem. It's was surprise for me that exceptions in these functions are not logged to console by default. |
Thanks for clarifying. But errors in these functions should be logged. There’s nothing special about React lifecycle methods from browser’s point of view. If they’re not, that’s a problem with your setup, not with React itself. If you share the project reproducing it, I can take a look at why this happens. |
Sure. Calls to lifecycle methods are instrumented with performance measurement calls in development. For example, we start a timer, then call your componentDidMount on the next line, then stop the timer. The same happens for render() method. This lets us later calculate how much time was spent in each component for ReactPerf measurements. Normally every To ensure this, My intention was to use this warning to prevent people forgetting to call The one thing I missed is that if the app’s code throws during a lifecycle hook like But apparently it is so common that errors get swallowed in React apps that people just don’t see the original error 😞 . I’m not sure why—this is why I’m asking people to share their examples. Maybe it’s a bad Promise polyfill, maybe it’s a I’m currently busy with create-react-app and couldn’t dedicate enough time into looking into this yet, sorry! |
I have this error when accessing a prop from the constructor constructor() {
super()
const { show } = this.props
} removing them or moving these statements to componentWillMount will help |
@vinhlh you have to do
|
Have you had a chance to read through my replies above? You’ll currently have this warning with any error in your code but you should see the real error alongside it. Is it not there? If not, please share a project reproducing this. |
i am facing the same problem in my app i ll try to find the code that caused it and publish it here. Note: i am using redux too |
I had exactly the same error in my application. I noticed that I had simply forgotten a comma in the json returned by my promise. When I corrected my json, everything is back in order. |
This example reproduces the warning if
(I originally posted this to a different issue, but I guess it should be posted here instead.) |
i noticed that i get this error whrn i print a props that is undefined inside a deep nested component . ecample. render () { return ( {name} )} } but when i do this i dont get the error render () { if (!name) return false return ( {name} )} } |
I got this error without any accompanying errors, and tracing back led me to finding out it was because of a syntax error while binding a
|
I got this error and it was to do with missing props on a render. My bad. Very simple to debug and fix, but the actual error message itself threw me a bit and brought me here. Good to read the reasons why it occurs |
Does anyone have a project I could run that reliably reproduces this? |
this happened a lot to me, but it was intermittent and was able to get rid On Tue, Aug 23, 2016 at 8:59 AM Dan Abramov [email protected]
|
* Ensure lifecycle timers are stopped on errors Fixes #7349 * Address review feedback and add an extra test
Fixed via #7548. This will be out in the next release. |
I've encountered these errors as well after upgrading React on a big project. My main issue is that on first render (after page reload), when I have some error somewhere that will break the initial rendering (eg. undefined used prop), I only get this error and nothing more. Also it often leads to 100% CPU usage and I have to manually kill the chrome process to properly reload. It's a pain! If I first reload to a working route and navigate to another route with a broken rendering I properly get both errors (this one + the actual one I'm interested in). I would thought that it would be caught by my root render try/catch but it isn't. Does anyone has encountered the same error swallowing behavior? const renderRootEl = (nextRoutes) => {
if (__DEV__) {
const RedBox = require('redbox-react').default; // eslint-disable-line global-require
try {
render(
<HotLoaderContainer errorReporter={RedBox}>
<Root store={store} routes={nextRoutes} />
</HotLoaderContainer>,
rootEl
);
} catch (err) {
render(
<RedBox error={err} />,
rootEl
);
}
} else {
render(
<Root store={store} routes={nextRoutes} />,
rootEl
);
}
};
renderRootEl(routes); |
This is most likely not React's fault. Try to simplify your setup until you see what swallows the real error. It might be some library you are using, a silent Promise polyfill, a hot reloading tool, your own catch() in a Promise or catch {} in code, etc. If you can demonstrate React swallowing an error, please file an issue with an example. |
@gaearon I'm also having the error |
This is fixed in React 15.3.2.
I believe I explained several times in this thread but let’s reiterate this once again. This warning is entirely unrelated to real errors. It cannot possibly cause your app to crash because it is a warning, not an error. It is not the reason your app crashes, but a consequence. This warning used to fire after your app code (not React) throws an error. An error in your component used to get performance measurement code into an inconsistent state, causing this warning. After React 15.3.2 you will not see this warning anymore. However that won’t solve errors in your application code which cause your app to crash. If for some reason you can’t see the real error, consider checking if your code swallows it in a try-catch somewhere, if some of your Babel plugins wrap your code in unexpected try-catches, if libraries you use wrap your code in try-catches, or if your Promise polyfill or native implementation swallows errors. |
Hope you don't mind me asking, but this error appears in my application sporadically and is accompanied by an error that suggests that
|
var thingOptions = thing[0] ? thing[0].options : null; ? |
@gaearon Ran into this state, searched, found myself in this thread. In my case, the error was a result of a copy/paste transposition; passing a container state down into nested components as a prop works better when you don't just paste In any case, the error was tricky to track down because it appeared BELOW the The structure that threw this was, basically: A container with an initial state of |
As I mentioned above, this warning doesn't show up since React 15.3.2. Please update React. |
If anyone is still seeing this in new versions of React, during tests, with Jasmine, let me save you some debugging: We were testing an HoC by creating a component to wrap in the test and calling Jasmine's |
Using React 15.5.4 and still get this warning. It also appears in 15.4.1:
Should I send details? |
You might be getting it if your code throws somewhere (check your console). You might also be swallowing exceptions in your code, so you don't see the issue. Try "break on all exceptions" in debugger and see if you can find it. If this is a legitimate false positive you could file an issue, but we likely won't fix it in 15 because that code is already removed from master, and we're working on the 16 release which diverged too much. |
Indeed. Cause was an error in my code in componentWillUnMount. |
Cool! If it doesn't get displayed in the console make sure you're not swallowing exceptions. It's generally bad if they go unnoticed. |
I know there are a lot of different ways that this error can occur, hope my case can help someone out there, In my case the error is related when the |
I have the same error in my project which uses ReactArt. Stack trace points to these lines. Not sure, but seems that it can be caused by calling |
I been getting this error quite frequently now, whenever a component is removed/unmounted |
As I said in every other comment in this thread, this error is just a symptom of another, real error in your code, that is being swallowed by your code (for example due to incorrect Promise handling). At this point I’d say the easiest way to fix it is to upgrade to React 16. React 16 is more error-resilient and will point out the real error earlier (which is in your code, not in React). I’m going to lock this because there are no further actionable items for us here. |
Not sure this should be filed as a bug, or if this is intended behaviour, in which case it would be more of a feature request, for something that we lost since the last few versions.
Which is more specific error logging.
Since the last few version this error shows up too many times, without any usable stack-trace:
There is an internal error in the React performance measurement code. Did not expect componentDidMount timer to start while render timer is still in progress for another instance.
This mainly occurs when a prop or state is not defined. This wouldn't be a big problem if I could stacktrace it, but in this case I cannot lead it back to any related component, I have to go off on what I changed last.
I do use
redux
and the stacktrace does go back to createStore and then connect, but this should not be related since this error shows up regardless of which element has an undefined property.It is also often accompanied by:
Uncaught TypeError: Cannot read property '_currentElement' of null
How do I debug this error? Or are there plans to improve this?
The text was updated successfully, but these errors were encountered: