about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorJeong Arm <kjwonmail@gmail.com>2022-01-10 22:25:08 +0900
committerGitHub <noreply@github.com>2022-01-10 14:25:08 +0100
commitbc7a8ae6d6d2c2118e5c49add83539498b9d543b (patch)
treeef8e47621abf0e79908c2100f5d4e017ca3c0e38 /app/javascript
parent3dc0357d9e901d930c6380e0fc7b455f627129fe (diff)
Gradually increase retry waiting for media processing (#17271)
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/actions/compose.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js
index 9b37085cb..94a4df418 100644
--- a/app/javascript/mastodon/actions/compose.js
+++ b/app/javascript/mastodon/actions/compose.js
@@ -252,12 +252,15 @@ export function uploadCompose(files) {
           if (status === 200) {
             dispatch(uploadComposeSuccess(data, f));
           } else if (status === 202) {
+            let tryCount = 1;
             const poll = () => {
               api(getState).get(`/api/v1/media/${data.id}`).then(response => {
                 if (response.status === 200) {
                   dispatch(uploadComposeSuccess(response.data, f));
                 } else if (response.status === 206) {
-                  setTimeout(() => poll(), 1000);
+                  let retryAfter = (Math.log2(tryCount) || 1) * 1000;
+                  tryCount += 1;
+                  setTimeout(() => poll(), retryAfter);
                 }
               }).catch(error => dispatch(uploadComposeFail(error)));
             };