@tinycloud/operations 0.6.1-beta.6 → 0.6.1-beta.8

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.cjs CHANGED
@@ -274,6 +274,18 @@ function storageFullOperationError(error) {
274
274
  { retryable: false, ...account === void 0 ? {} : { details: { account } } }
275
275
  );
276
276
  }
277
+ function nodeRetryOperationError(error) {
278
+ const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
279
+ if (code === "OUTCOME_UNKNOWN") {
280
+ return operationError(
281
+ "NODE_ERROR",
282
+ "The TinyCloud node may have applied the write; read the data back before retrying.",
283
+ { retryable: false }
284
+ );
285
+ }
286
+ if (code !== "NODE_BUSY" && code !== "REQUEST_TIMEOUT") return void 0;
287
+ return operationError("NODE_ERROR", "The TinyCloud node was busy and applied nothing; try again shortly.", { retryable: true });
288
+ }
277
289
  function isOperationErrorCode(value) {
278
290
  return typeof value === "string" && OPERATION_ERROR_CODES.includes(value);
279
291
  }
@@ -6535,6 +6547,8 @@ function appsFailure(error) {
6535
6547
  if (auth?.status === "error") return auth.error;
6536
6548
  const storage = storageFullOperationError(error);
6537
6549
  if (storage) return storage;
6550
+ const nodeRetry = nodeRetryOperationError(error);
6551
+ if (nodeRetry) return nodeRetry;
6538
6552
  const code = typeof error === "object" && error !== null ? error.code : void 0;
6539
6553
  if (code === "SPACE_NOT_HOSTED") return operationError("NODE_ERROR", "Your TinyCloud default space is not set up. Try again in a minute; if it still fails, ask for help setting up the space.", { details: { reason: "space_not_hosted" } });
6540
6554
  if (isOperationErrorCode(code)) return operationError(code, "The node could not complete this personal-record operation.");
@@ -8008,16 +8022,8 @@ function kvFailure(error, action) {
8008
8022
  if (error.code === "KV_PRECONDITION_FAILED") {
8009
8023
  return { status: "error", error: operationError("KV_PRECONDITION_FAILED", "The TinyCloud KV object changed or already exists.") };
8010
8024
  }
8011
- if (error.code === "KV_CONFLICT") {
8012
- return {
8013
- status: "error",
8014
- error: operationError(
8015
- "KV_CONFLICT",
8016
- "A database serialization conflict prevented the conditional KV mutation; re-read the key state, which may still be absent, before deciding whether to retry.",
8017
- { retryable: true }
8018
- )
8019
- };
8020
- }
8025
+ const nodeRetry = nodeRetryOperationError(error);
8026
+ if (nodeRetry) return { status: "error", error: nodeRetry };
8021
8027
  if (error.code === "KV_RESPONSE_TOO_LARGE") {
8022
8028
  return { status: "error", error: operationError("KV_RESPONSE_TOO_LARGE", `The TinyCloud KV value exceeds ${MAX_KV_VALUE_BYTES} bytes.`) };
8023
8029
  }