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

Fixes: Cannot read properties of undefined (reading '_custom') by checking 'parsed' before using it #11581

Closed
wants to merge 3 commits into from

Conversation

mbonaci
Copy link

@mbonaci mbonaci commented Nov 13, 2023

In getLabelAndValue controller.bar.js.

There's already a similar issue filed here: #11365
Though mine happens in bar charts and this one seems to be in the doughnut, but the issue is the same.

This illusive error happens very rarely and it turned out to be impossible to reproduce, but I keep getting this error from our users in our bug tracking system.

Please advise if you think there's a better way to fix the issue than to return a dummy label/value.
This parsed thing is basically dataset meta that was previously cached.

…re using it

Fixes: Cannot read properties of undefined (reading '_custom') in Bar chart
@ajaymahadeven
Copy link

ajaymahadeven commented Nov 16, 2023

I've faced this quite a similar issue and it might help, What I did was basically make pre - check the parent objects before accessing the children.

Before the code accessed the chartInstance directly :
chartInstance = chartRef.current.$context.chart;

When the component was initially being rendered the $context was almost always undefined.

After placing the pre-checks , it negated the error as I placed its calling under an useEffect to keep checking until after the component was rendered completly.


if (chartRef.current) {
        if (chartRef.current.$context) {
          chartInstance = chartRef.current.$context.chart;
        }

@etimberg etimberg requested a review from kurkle November 17, 2023 14:40
…'parsed' in not set

Because a test was failing: 
Types of property 'value' are incompatible.
Type 'number' is not assignable to type 'string'.
@joshkel
Copy link
Contributor

joshkel commented Nov 28, 2023

If both bar and donut charts have similar errors, then it seems ideal to instead find a common location to fix all controllers, if possible?

I have an alternative candidate fix at #11596; I'm not sure if that approach is better or not.

@mbonaci
Copy link
Author

mbonaci commented Nov 30, 2023

Resolved by 429d99d, closing.

@mbonaci mbonaci closed this Nov 30, 2023
@mbonaci mbonaci deleted the patch-1 branch November 30, 2023 13:22
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 this pull request may close these issues.

3 participants