lightweight-charts: Improve error message for: Error: Value is null at ensureNotNull (lightweight-charts.development.mjs:205:15)
Lightweight Charts™ Version:
4.2.0 🚭
Steps/code to reproduce:
I have a React Hook that updates lines, candles and Area chart based on different states of my app.
It generally works but sometimes i get that error
Error: Value is null at ensureNotNull (lightweight-charts.development.mjs:205:15)
When I look through the stack trace, the further I can go is a requestAnimationFrame; making it very hard to figure out where the null value is coming from.
Ideally, the error message would have a label indicating what kind of value is null, making it easier to debug and figure out where the null value is coming from.
When this happens, the entire chart doesn’t render, which is a big issue. It also makes me wonder if some sort of try/catch should exist in the library so that other parts of the chart would still render and not get affected if only a LINE or an AREA chart has a null value.
I’m assuming it’s very unlikely the problem is with the candles as the candles actually don’t change so it would be really helpful if at least the candles would render.
Still, there is a chance a candle that comes with null from a third-party API from time to time could have a null value (I’m still figuring it out).
Unfortunately, this error occurs very rarely, making it difficult to reproduce and determine the source of the problem.
Could we add a string to this error pointing out which type of value or series the problem is?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (7 by maintainers)
Had same error with no clue where to start digging in to resolve issue.
This was helpful. Thanks
If you were to keep track of the last timestamp of data that you’ve provided to the library then you could do something like this (types might be wrong since I’m doing this from memory):
Sure thing, i understand all of that.
What i suggested tough is when we do
setDatafor the candles the library should internally “erase” the previous array.In my case i do
setData([])to avoid that problem which i guessed the library could also do internally to avoid the problem i was having.TLDR:
Hook with this triggers the problem:
Hook with this, doesn’t trigger the problem:
Conclusion: maybe internally when new candles are set the previous candles could be erased the same way i did.