Skip to content

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KuznetsovRoman
Copy link
Member

No description provided.

Copy link

pkg-pr-new bot commented Apr 18, 2025

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/html-reporter@654

commit: f420a3b

@@ -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});
Copy link
Member Author

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

Copy link
Member

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}`});
Copy link
Member Author

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) {
Copy link
Member Author

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

Copy link
Member

@shadowusr shadowusr left a 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});
Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants