Sending many requests for video/audio upload while editing post

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:

https://github.com/discourse/discourse/blob/0967ce478d85ad5053522944b36ed9212f867457/app/assets/javascripts/pretty-text/addon/upload-short-url.js#L152

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 https://github.com/discourse/discourse/pull/10511. Thank you for the detailed bug report by the way! @kkurdupov

4 Likes