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:

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