Skip to content

Commit

Permalink
Do not retry update requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustem Mussabekov committed Nov 6, 2023
1 parent 0c5eec6 commit 375c7b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/data/modules/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import ApiError from './error'

function* get(url, overrideOptions={}) {
const res = yield req(url, overrideOptions)
const res = yield req(url, overrideOptions, API_RETRIES)

var json = {}
if (res.headers){
Expand Down Expand Up @@ -99,7 +99,7 @@ function* del(url, data={}, options={}) {
return json;
}

function* req(url, options={}) {
function* req(url, options={}, retries=0) {
var finalURL = API_ENDPOINT_URL + url

if (url.indexOf('/') == 0)
Expand All @@ -109,7 +109,8 @@ function* req(url, options={}) {

let errorMessage = 'failed to load'

for(let i = 0; i < API_RETRIES; i++){
for(let i = 0; i <= retries; i++){
console.log(i, retries)
try{
const winner = yield race({
req: call(fetchWrap, finalURL, {...defaultOptions, ...options}),
Expand All @@ -127,8 +128,8 @@ function* req(url, options={}) {
if (e && e.status && e.status >= 400 && e.status < 500)
break;
//retry
else if(i < API_RETRIES-1) {
yield delay(100 + (API_RETRIES * 100) ); //stop 100ms and try again
else if(i < retries-1) {
yield delay(100 + (retries * 100) ); //stop 100ms and try again
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/routes/extension/tabs/useSubmit.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export default function ExtensionTabsSubmit({ tabs, collectionId, tags, close })
//save
dispatch(
manyCreate(
tabs.map(({title, url})=>({
title,
link: url,
collectionId,
tags
})),
tabs
.reverse() //make sure first is first
.map(({title, url})=>({
title,
link: url,
collectionId,
tags
})),
async()=>{
if (close)
await browser.tabs.remove(tabs.map(({id})=>id))
Expand Down

0 comments on commit 375c7b7

Please sign in to comment.