Charts sometimes randomly not generating (timing out?)

Firstly, thanks for this tool - it’s wonderful.

After quite a lot of hassle I’ve reached a setup that shows the charts I want. I’m calling these once per day so nothing egregious, and just two charts.

80% of the time it works fine. Exactly the same template/function creating the chart. The data barely changes even; sometimes it even doesn’t change at all.

And yet sometimes, it just doesn’t work - apologies as I don’t have a precise error on hand to give you, but I notice it as my discord webhook (which posts the chart url/image) sometimes displays an empty box. It’s not a discord issue though as I did have this happening sometimes when testing the chart URL output on its own.

It’s as if it’s timing out occasionally, or as if it’s simply failing? Because when it happened in the past during testing, I could immediately re-call the function and it would work. It’s like there’s nothing wrong but it just sometimes is too busy to perform?

Ok, I did some more testing and this does seem to be due to timing out.

Again - this is extremely weird to me for a number of reasons. Sometimes, with the same setup, it works perfectly. Other times - about 50% of the time - it will load the Chart URL and display an image that says “Error timeout - exceeded 2000ms” (paraphrased).

HOWEVER, if I click/load the same URL link again immediately, it will load properly (and work from then on).

What is going on here? How can this be avoided? Why would it happen only 50% of the time and why does it work the second time you access the link?

This is resulting in failed embeds/posts to discord, not to mention being a strange bug in itself.

Hi @orzcodedev, thanks for the report.

Are you using the /chart API, or /chart/create?

Any chance you can send us an example chart? We’ll look into it. You can also send by email if that’s preferred.

Thank you so much for your reply.

I am using /chart/create as I need the shorter URL - I think it was Discord that required this due to their 2000 character limit, if my memory serves.

Here’s an example URL which I haven’t accessed yet, but I can see it hasn’t auto-resolved / auto-completed when it was sent to Discord this morning:


I am pretty sure the first time you click that, it will show an error, but clicking it again will load the chart?

EDIT: it seems that by posting this, it resolved the chart. However, it didn’t/wasn’t working at the time it was posted to discord via my pipeline, much like the others on a seemingly random basis.

Thanks again

Hi @orzcodedev,

So, for short URLs, it can take a couple seconds for them to become active globally. Unfortunately, before then they will 404 (that doesn’t explain why you’re seeing a timeout error - I will look into that). Usually the delay is just a couple milliseconds, but in some cases (especially large batches) it can be longer.

We don’t have a blocking creation endpoint for short URLs, although that is on the roadmap.

When you see the timeout message, is it an image or a text output?

Hi Ian,

Thank you so much for your response.

Firstly, the error I’ve been seeing is indeed an actual image. “Error: timeout 2000ms exceeded” (or similar). Reloading or re-visiting the same URL will fix it and display the proper chart. I should note, this seems to happen without rhyme or reason - usually it works fine, maybe 40% of the time it doesn’t and results in that error image.

To give you some more context, I’m only creating two graphs at a time, once per week (currently once per day, just for testing). So no large batches.

I initially thought I might get around the issue by running my chart creation function, and then pausing/‘Awaiting’ for 5 seconds before sending the URL to Discord - this didn’t help though. So currently, I am trying something else - running my chart creation function and then doing a fetch request to the URL, but not actually doing anything with it (not sending it anywhere etc - just ‘pinging’ it so to speak). I’ve only been doing this a couple of days now and so far it’s going ok, though it’s too early to say I guess.

Just for your reference, this is what that pre-fetch function looks like:

const prewarmCharts = (chartUrls) =>
Promise.all(
chartUrls.map(url =>
fetch(url, { method: “GET”, cache: “no-store” })
.then(r => r.arrayBuffer())
.catch(() => {})
)
);

I will mention one curiosity however - the other day however, I saw something odd:

image.png

As you can see, it appears to have bugged out after only partly composing the graph. I’ve tried visiting this same URL just now and it’s rendering properly (though again, the first visit just now did give the timeout error). I just thought i’d mention this as it was rather weird - this has only happened once so far, after I added the pre-fetch mentioned above. It could be completely unrelated though.

If you have any thoughts please feel free to share, otherwise I am hoping that my ‘pre-fetch’ will solve the issue and I shall monitor it over the coming days. I am just a junior dev though, so if I’m barking up the wrong tree with this idea I’m happy to hear it.

Thanks again for your time