Perchance Saving Bugs
There were a few instances where in the editor ended up failing to “save”, but the generator saving process still succeeded and is still recorded in the revisions.
I was editing my generator hub page that day and saved it by clicking on the save button and then it errors after a classic 20 seconds…
I decided to check the DevTools network and it shows all the details behind that saving process, and things look suspicious, until the revisions told me wrong.
Thanks for the code snippet, I’m actually working on another Generator Manager update and have started to implement this into the total view calculation function (
totalStats()
). Though I’m not sure if this could be used for the view counters in the generator items.For now, the code for the function looks a bit like this:
Code for a future Generator Manager update
async function totalStats() { // We already had the URLs from all the generators on the page and compiled them through the all_link variable let tot = await fetch("https://perchance.org/api/getGeneratorStats?names="+all_link.joinItems(",")).then(r => r.json()); let ftot = 0; for (let v of tot.data.map(x => x.views)) { ftot += v; // Add up to make the total views } // We need to set two total view counters in the top banner and on the Statistics section in the About page for (let el of document.querySelectorAll(".tstxt")) { el.innerHTML = enableRawStats ? ftot.toLocaleString() : formatNumber(ftot); } // Set the total views counter in the top banner }; totalStats();
The
totalStats()
function is now an async function and sets the total view counter on the top banner right away instead of just returning the value of it, so this time I no longer need a timer that does this job consecutively anymore. And this greatly reduced the delay for the total views counter to appear.Is this implementation still triggers the “error” whenever the save fails after 20 seconds, and instead of staying on the “saving…” state indefinitely? I see that nowadays it still occasionally ends up on the “error” state.
@perchance@lemmy.world pinging once again.
Does it get suck on ‘error’? Occasional errors (like once every few days maybe) are normal but it shouldn’t get stuck there.
IIRC sometimes it did end up on the “error” and goes back to the save button. Maybe that is because of bad connection or something, I’ve been receiving a lot of occasional delays (that took up to 30 minutes to just load a generator) but not as common as now. Maybe that’s why it affected the save, because that loading process also interferes the saving function.
Edit: Yeah, as of right now, when I’m saving my hub page, the “bad connection” thing happened, and the save button remained on “saving” state when the console told me that the 20-second timeout was exceeded. This is strange, because before that the save button would end up on the “error” state.