bytifi 0.2.5 → 0.2.6
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/lib/upload.js +9 -2
- package/package.json +1 -1
package/lib/upload.js
CHANGED
|
@@ -153,6 +153,7 @@ async function apiFetchWithRetry(baseUrl, path, options = {}) {
|
|
|
153
153
|
const {
|
|
154
154
|
retries = MAX_RETRIES,
|
|
155
155
|
rateLimitRetries = 0,
|
|
156
|
+
maxRateLimitWaitMs = null,
|
|
156
157
|
onStatus,
|
|
157
158
|
signal,
|
|
158
159
|
...fetchOptions
|
|
@@ -178,11 +179,16 @@ async function apiFetchWithRetry(baseUrl, path, options = {}) {
|
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
rateLimitAttempt += 1
|
|
181
|
-
const
|
|
182
|
+
const serverWaitMs = error.retryAfterMs ?? Math.min(600_000, 15_000 * rateLimitAttempt)
|
|
183
|
+
const waitMs = maxRateLimitWaitMs == null
|
|
184
|
+
? serverWaitMs
|
|
185
|
+
: Math.min(serverWaitMs, maxRateLimitWaitMs)
|
|
182
186
|
|
|
183
187
|
onStatus?.({
|
|
184
188
|
stage: 'waiting',
|
|
185
|
-
message:
|
|
189
|
+
message: maxRateLimitWaitMs != null && serverWaitMs > waitMs
|
|
190
|
+
? `Rate limited — retrying in ${formatDuration(waitMs)} (part upload continues when server allows)…`
|
|
191
|
+
: `Rate limited — waiting ${formatDuration(waitMs)} before retry (${rateLimitAttempt})…`,
|
|
186
192
|
waitMs,
|
|
187
193
|
retryAttempt: rateLimitAttempt,
|
|
188
194
|
})
|
|
@@ -453,6 +459,7 @@ async function uploadMultipartStreaming(filePath, context, {
|
|
|
453
459
|
signal,
|
|
454
460
|
onStatus,
|
|
455
461
|
rateLimitRetries: UNLIMITED_RATE_LIMIT_RETRIES,
|
|
462
|
+
maxRateLimitWaitMs: 15_000,
|
|
456
463
|
},
|
|
457
464
|
)
|
|
458
465
|
|