Veel verzoeken verzenden voor video/audio-upload tijdens het bewerken van een bericht

AI-generated summary

A bug was reported by kkurdupov in Discourse versions v2.4.5, v2.5.0, and 2.6 beta, where editing a post containing video/audio uploads triggers excessive upload requests with every keystroke. This behavior causes API rate limiting and potential auto-signouts. The issue stems from line 152 in upload-short-url.js, which re-calls the video/audio DOM element’s load function on every preview render. simon noted that disabling cache in Chrome’s dev tools could reproduce the issue, but kkurdupov clarified that cache settings shouldn’t affect request frequency — the root cause is DOM recreation during preview rendering. martin confirmed partial reproduction and found the problematic line was no longer necessary, as video previews function correctly without it. He submitted and merged a fix to remove the line, resolving the spammy upload requests. The fix was acknowledged with thanks to kkurdupov for the detailed report.

Hello everyone! I would like to submit a bug.
Reproduced on v2.4.5, v2.5.0.

Prerequisites

  • Create a post with a video/audio upload in it.
  • I have tested it with secure media upload, but should be reproduced with not secure media.
  • Start edit the post.
  • Open browser’s developer console. Optionally, set filter for upload API.
  • Wait for all requests finished and clear console.

Steps to reproduce

  • Type anything in left(editing) area.
  • Check browser’s dev console.

Actual result

  • Every keystroke is considered change so simplify typing is constantly creating video upload events.
  • A lot of changes will cause sending massive of requests, then denying requests because of API Rate Limit and auto signing out of forum.

Expected result

  • No requests for audio/video upload while editing post

See the gif:

Note about the bug:

This line produces the bug. It calls load function of <video>/<audio> DOM element each time on preview rendering, in fact each time of a post change.

3 likes

Does it persist in 2.6 beta?

Yes, it persists in 2.6beta as well as in the latest commit(208d85aaff0392a3a796f84ea78670def6ed7b8e) of test-passed branch .

That is odd. I can only reproduce the issue if I select the “Disable cache” checkbox on my web inspector’s Network tab. When I deselect “Disable cache” I get the expected results. I’m using Chrome on Ubuntu. From your video, you don’t seem to have “Disable cache” selected, so I’m not sure what is causing the difference.

1 like

“Disable cache” must not affect on sending requests. It affects on where a result of a request comes from - from browser’s cache or from real source.

Those upload requests are sent by the code that re-renders preview every keystroke which causes to create new video/audio DOM element. So load is called for a new DOM element what definitely must send a request.
Even if it would be a “cached”(not every time newly created) DOM element then it sent a request only one time regardless of “Disable cache”.

I took a look at this and I can somewhat reproduce it with secure and non-secure video uploads. At a certain point it seems to cache and stop spamming these requests but it is still a problem. The line you pointed out:

Was added by me, but it doesn’t actually seem to affect anything now. If I remove it the video previews still work fine. I know we have done other work with video thumbnails etc. which have probably fixed whatever issue I put this line here for. So I think I will just remove this which resolves the multiple request issue.

3 likes

Merged a fix FIX: Remove unnecessary audio/video parent element load by martin-brennan · Pull Request #10511 · discourse/discourse · GitHub. Thank you for the detailed bug report by the way! @kkurdupov

4 likes