diff --git a/packages/manager/src/managers/screenshots/ScreenshotsManager.ts b/packages/manager/src/managers/screenshots/ScreenshotsManager.ts index 3288bd097a..25f222eaa1 100644 --- a/packages/manager/src/managers/screenshots/ScreenshotsManager.ts +++ b/packages/manager/src/managers/screenshots/ScreenshotsManager.ts @@ -1,5 +1,6 @@ import * as t from "io-ts"; import { fileTypeFromBuffer } from "file-type"; +import pLimit from "p-limit"; import fetch, { FormData, Blob, Response } from "../../lib/fetch"; import { checkIsURLAccessible } from "../../lib/checkIsURLAccessible"; @@ -47,6 +48,8 @@ function assertBrowserContextInitialized( } } +const uploadScreenshotLimit = pLimit(10); + /** * Encodes a part of a Slice Simulator URL to ensure it can be added to a URL * safely. @@ -283,10 +286,13 @@ export class ScreenshotsManager extends BaseManager { formData.set("file", new Blob([args.data], { type: fileType?.mime })); - const res = await fetch(this._s3ACL.uploadEndpoint, { - method: "POST", - body: formData, - }); + const s3ACLEndpoint = this._s3ACL.uploadEndpoint; + const res = await uploadScreenshotLimit(() => + fetch(s3ACLEndpoint, { + method: "POST", + body: formData, + }), + ); if (res.ok) { const url = new URL(key, this._s3ACL.imgixEndpoint);