@pixeyedev/storybook 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/upload.js +18 -9
- package/package.json +1 -1
package/dist/upload.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PixeyeError } from '@pixeyedev/core';
|
|
1
|
+
import { isRetryableHttpError, maskPresignedUrl, PixeyeError, withRetry } from '@pixeyedev/core';
|
|
2
2
|
import { StorybookFinalizeResponseSchema, StorybookUploadResponseSchema } from '@pixeyedev/shared';
|
|
3
3
|
/**
|
|
4
4
|
* Upload a Storybook bundle to Pixeye for server-side rendering.
|
|
@@ -36,15 +36,24 @@ export const uploadBundle = async (opts) => {
|
|
|
36
36
|
const skipped = uploadData.bundleExists;
|
|
37
37
|
// Step 2: Upload bundle to presigned URL (skip if already exists)
|
|
38
38
|
if (!skipped) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
const maskedUrl = maskPresignedUrl(uploadData.presignedUrl);
|
|
40
|
+
await withRetry(async () => {
|
|
41
|
+
const putRes = await fetch(uploadData.presignedUrl, {
|
|
42
|
+
method: 'PUT',
|
|
43
|
+
body: new Uint8Array(opts.buffer),
|
|
44
|
+
headers: { 'Content-Type': 'application/gzip' }
|
|
45
|
+
});
|
|
46
|
+
if (!putRes.ok) {
|
|
47
|
+
const text = await putRes.text();
|
|
48
|
+
throw new PixeyeError(putRes.status, maskedUrl, text);
|
|
49
|
+
}
|
|
50
|
+
}, isRetryableHttpError, {
|
|
51
|
+
maxAttempts: 3,
|
|
52
|
+
baseDelayMs: 1000,
|
|
53
|
+
onRetry: (attempt, err) => {
|
|
54
|
+
console.warn(`[pixeye] Bundle upload retry ${attempt}/3: ${err.message}`);
|
|
55
|
+
}
|
|
43
56
|
});
|
|
44
|
-
if (!putRes.ok) {
|
|
45
|
-
const text = await putRes.text();
|
|
46
|
-
throw new PixeyeError(putRes.status, 'presigned-put', text);
|
|
47
|
-
}
|
|
48
57
|
}
|
|
49
58
|
// Step 3: Finalize — creates build + pipeline, enqueues render job
|
|
50
59
|
const finalizeRes = await fetch(`${baseUrl}/api/v1/storybook/uploads/${uploadData.uploadId}/finalize`, {
|