-
Notifications
You must be signed in to change notification settings - Fork 51
fix: static accepter image load fail #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
commit: |
@@ -83,13 +84,19 @@ export const staticAccepterCommitScreenshot = ( | |||
payload.append('meta', JSON.stringify(meta)); | |||
} | |||
|
|||
await Promise.all(imagesInfo.map(async (imageInfo, index) => { | |||
dispatch({type: actionNames.UPDATE_LOADING_TITLE, payload: `Preparing images to commit: ${index + 1} of ${imagesInfo.length}`}); | |||
const queue = new PQueue({concurrency: 256}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we limit number of image load requests by 256.
Looks like every browser can handle 256 requests at the same time, and this number seems reasonable as http/2 supports this amount.
But if there are too many requests, browser can have some difficulties
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this works then ok, but if 256 is the max value in most browsers, maybe it's worth limiting it slightly below the limit to preserve room for other, unrelated to images uploading requests? For example, so that when user is uploading images, he could still use report (including downloading time travel snapshots or downloading screenshots for other tests).
})); | ||
payload.append('image', blob, imagesInfo[i].path); | ||
|
||
dispatch({type: actionNames.UPDATE_LOADING_TITLE, payload: `Preparing images to commit: ${i + 1} of ${imagesInfo.length}`}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dispatching this action after the blob is downloaded seems more suitable.
Example: we have 256 images.
Before:
We instantly dispatch 256 actions and user sees "preparing to commit: 256/256" (and only after we only start downloading these images)
After:
We update the counter after download is complete. So at start user will see "0/256" while nothing was downloaded
export function getBlob(url) { | ||
return new Promise((resolve, reject) => { | ||
const xhr = new XMLHttpRequest(); | ||
export async function getBlobWithRetires(url, retriesCount = 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also be rps limited
So exponential retries (1s, 2s, 4s) would not be superfluous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome enhancement! 🔥
@@ -83,13 +84,19 @@ export const staticAccepterCommitScreenshot = ( | |||
payload.append('meta', JSON.stringify(meta)); | |||
} | |||
|
|||
await Promise.all(imagesInfo.map(async (imageInfo, index) => { | |||
dispatch({type: actionNames.UPDATE_LOADING_TITLE, payload: `Preparing images to commit: ${index + 1} of ${imagesInfo.length}`}); | |||
const queue = new PQueue({concurrency: 256}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this works then ok, but if 256 is the max value in most browsers, maybe it's worth limiting it slightly below the limit to preserve room for other, unrelated to images uploading requests? For example, so that when user is uploading images, he could still use report (including downloading time travel snapshots or downloading screenshots for other tests).
No description provided.