notte-sdk 1.10.20 → 1.10.21
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/index.d.mts +52 -3
- package/dist/index.d.ts +52 -3
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -5
- package/dist/index.mjs.map +1 -1
- package/dist/proxy/core.js +14 -7
- package/dist/proxy/core.js.map +1 -1
- package/dist/proxy/core.mjs +14 -7
- package/dist/proxy/core.mjs.map +1 -1
- package/dist/proxy/next.js +14 -7
- package/dist/proxy/next.js.map +1 -1
- package/dist/proxy/next.mjs +14 -7
- package/dist/proxy/next.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var SDK_VERSION = true ? "1.10.
|
|
2
|
+
var SDK_VERSION = true ? "1.10.21" : "dev";
|
|
3
3
|
var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
|
|
4
4
|
|
|
5
5
|
// src/version-check.ts
|
|
@@ -3259,6 +3259,7 @@ var RETRY_AFTER_MAX_MS = 2e4;
|
|
|
3259
3259
|
var IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "PUT", "DELETE"]);
|
|
3260
3260
|
var REFUSED_STATUSES = /* @__PURE__ */ new Set([503, 529]);
|
|
3261
3261
|
var GATEWAY_STATUSES = /* @__PURE__ */ new Set([502, 504]);
|
|
3262
|
+
var WORKER_TIMEOUT_ERROR_CLASS = "WorkerRequestTimeout";
|
|
3262
3263
|
var NOT_SENT_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
3263
3264
|
"ECONNREFUSED",
|
|
3264
3265
|
"EAI_AGAIN",
|
|
@@ -3276,7 +3277,8 @@ var BROKEN_CONNECTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
3276
3277
|
function isIdempotentMethod(method) {
|
|
3277
3278
|
return IDEMPOTENT_METHODS.has(method.toUpperCase());
|
|
3278
3279
|
}
|
|
3279
|
-
function isRetryableStatus(status, method) {
|
|
3280
|
+
function isRetryableStatus(status, method, errorClass) {
|
|
3281
|
+
if (status === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) return isIdempotentMethod(method);
|
|
3280
3282
|
return REFUSED_STATUSES.has(status) || GATEWAY_STATUSES.has(status) && isIdempotentMethod(method);
|
|
3281
3283
|
}
|
|
3282
3284
|
function isRetryableNetworkError(error, method) {
|
|
@@ -3328,7 +3330,7 @@ function createRetryingFetch(options) {
|
|
|
3328
3330
|
await wait2(delay4, signal);
|
|
3329
3331
|
continue;
|
|
3330
3332
|
}
|
|
3331
|
-
if (last || !isRetryableStatus(response.status, method)) return response;
|
|
3333
|
+
if (last || !isRetryableStatus(response.status, method, response.headers.get("x-error-class"))) return response;
|
|
3332
3334
|
const delay3 = retryDelayMs(attempt, response.headers.get("retry-after"), options.random);
|
|
3333
3335
|
if (delay3 === void 0 || !fitsDeadline(delay3)) return response;
|
|
3334
3336
|
await response.body?.cancel().catch(() => void 0);
|
|
@@ -3508,7 +3510,9 @@ var Session = class {
|
|
|
3508
3510
|
* (`NotteClientConfig.maxRetries`, honoring `Retry-After`). Other 5xx
|
|
3509
3511
|
* errors are retried up to `SESSION_START_TRIES` times. With client
|
|
3510
3512
|
* retries disabled, 529 waits `CLUSTER_OVERLOAD_RETRY_DELAY_MS` instead.
|
|
3511
|
-
* 4xx errors are never retried
|
|
3513
|
+
* 4xx errors are never retried, nor is a 529 marked
|
|
3514
|
+
* `X-Error-Class: WorkerRequestTimeout`: an API worker did not answer in
|
|
3515
|
+
* time and may already have created the session.
|
|
3512
3516
|
*
|
|
3513
3517
|
* Managed-auth sessions wait for readiness by default. Pass
|
|
3514
3518
|
* `{ wait_for_authentication: false }` for an explicit nonblocking start,
|
|
@@ -3563,7 +3567,11 @@ var Session = class {
|
|
|
3563
3567
|
sessionData = response.data;
|
|
3564
3568
|
break;
|
|
3565
3569
|
} catch (error) {
|
|
3566
|
-
const
|
|
3570
|
+
const errorClass = error instanceof NotteAPIError ? error.response?.headers.get("x-error-class") : void 0;
|
|
3571
|
+
if (error instanceof NotteAPIError && error.statusCode === 529 && errorClass === WORKER_TIMEOUT_ERROR_CLASS) {
|
|
3572
|
+
throw error;
|
|
3573
|
+
}
|
|
3574
|
+
const transient = error instanceof NotteAPIError ? isRetryableStatus(error.statusCode, "POST", errorClass) : isRetryableNetworkError(error, "POST");
|
|
3567
3575
|
if (maxRetries > 0 && transient) {
|
|
3568
3576
|
const wait2 = transientRetries >= maxRetries ? void 0 : error instanceof NotteAPIError ? retryDelayMs(transientRetries, error.response?.headers.get("retry-after")) : backoffDelayMs(transientRetries);
|
|
3569
3577
|
if (wait2 === void 0 || !fitsDeadline(wait2)) throw error;
|