This repository was archived by the owner on Apr 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
This repository was archived by the owner on Apr 6, 2024. It is now read-only.
Don't fire all the fetch() requests at once #9
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
This thing HAMMERS the backend:
datasette-paste/datasette_paste/templates/paste_create_table.html
Lines 207 to 230 in 450f0ec
| for (let i = 0; i < currentRows.length; i += batchSize) { | |
| const batch = currentRows.slice(i, i + batchSize); | |
| fetch(url, { | |
| method: 'POST', | |
| headers: headers, | |
| body: JSON.stringify({table: table, rows: batch}) | |
| }).then(response => { | |
| if (!response.ok) { | |
| throw new Error('Failed to upload rows: ' + response.statusText); | |
| } | |
| return response.json(); | |
| }).then(json => { | |
| if (json.ok) { | |
| progressBar.value += batch.length; | |
| if (progressBar.value === progressBar.max) { | |
| window.location = json.table_url; | |
| } | |
| } else { | |
| alert('Error uploading rows: ' + json.error); | |
| } | |
| }).catch(error => { | |
| alert('Error uploading rows: ' + error); | |
| }); | |
| } |
That sends fetch() requests at the maximum rate allowed by the browser. It would be better to limit them to maybe 3 in parallel at a time?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request