Skip to main content

SquareCloudBlobError

Every API failure throws a SquareCloudBlobError.

What is not a SquareCloudBlobError

  • Network errors are not wrapped. When a request gets no complete response (DNS failure, connection reset, a body cut off mid-read), the original fetch error is thrown as-is, after any retries.
  • File errors. In Node.js, a put() path that cannot be opened throws a plain Error (Cannot open the file "<path>". Check that the path exists and that this process can read it., original error in cause). Outside Node.js, any path throws a plain Error (File paths can only be uploaded in Node.js. Pass a Blob, a File or bytes instead.).
  • A missing @aws-sdk/client-s3. s3() throws a plain Error that says how to install it, or to pass s3Credentials() to another S3 client, with the import error in cause.
These messages changed in 4.2.0: code that compares them must use the new text.

UNKNOWN_ERROR

UNKNOWN_ERROR is the only code that does not come from the service. It is used when the response has no error code: a non-JSON body (a proxy error page, for example) or a 2xx response without status: "success". status still holds the real HTTP status, and message names that status and the likely cause (before 4.2.0, it was the code itself).

Per-object failures

Batch operations report failures in their result instead of throwing:
  • update(): each result has ok: false and a code.
  • delete([ids]): missing objects go to not_found, other failures to failed.

Error codes

BlobErrorCode is the Blob Storage API’s own list of codes. It is not the same list as the main Square Cloud API’s error codes. For each code’s HTTP status and meaning, see the Blob API errors reference.
ACCESS_DENIED, RATE_LIMITED, MISSING_SCOPE, RESOURCE_NOT_ALLOWED, UPLOAD_TOKEN_NOT_ALLOWED, UPLOAD_TOKEN_USED, PREFIX_NOT_ALLOWED, PERMISSION_DENIED, ACCOUNT_BLOCKED, UPGRADE_REQUIRED, STORAGE_QUOTA_EXCEEDED, PRIVATE_STORAGE_UNAVAILABLE, PUBLIC_STORAGE_UNAVAILABLE, TOO_MANY_CONCURRENT_UPLOADS, UPLOAD_FAILED, STORAGE_UNAVAILABLE, INTERNAL_SERVER_ERROR, NOT_FOUNDSTORAGE_UNAVAILABLE (503) means storage is briefly unreachable. See Storage outages.RATE_LIMIT is deprecated: the service no longer sends it (see RATE_LIMITED), but it stays in the type.
OBJECT_NOT_FOUND, OBJECT_ALREADY_EXISTS, CHECKSUM_MISMATCH, INVALID_CONTENT_TYPE, FILE_TOO_LARGE, FILE_TOO_SMALL, BLOCKED_FILE_TYPE, INVALID_FILE_TYPE, FILE_TYPE_NOT_ALLOWED, NOTHING_TO_UPDATE, VISIBILITY_CHANGE_FAILED, UPDATE_FAILED, DELETE_FAILED, TOO_MANY_OBJECTS, SAME_OBJECT, INVALID_DESTINATION, COPY_FAILED, PREFIX_REQUIRED, INVALID_CONTINUATION_TOKENOBJECT_IS_LEGACY is deprecated: the service no longer sends it, but it stays in the type.
TOO_MANY_CONCURRENT_CHUNKS, TOO_MANY_OPEN_UPLOADS, INVALID_UPLOAD_TOKEN, UPLOAD_NOT_FOUND, NO_CHUNKS_UPLOADED, EMPTY_CHUNK, INVALID_CHUNK_PART, CHUNK_TOO_SMALL, CHUNK_TOO_LARGE
TOO_MANY_RULES, DUPLICATE_RULE_PREFIX, INVALID_RULES, UPLOAD_TOKEN_TOO_LARGE, TOO_MANY_SHARES, SHARE_NOT_FOUND, INVALID_SHARE, API_KEY_REQUIREDLEGACY_API_KEY is deprecated: the service no longer sends it, and an old API key gets 401 ACCESS_DENIED like any unknown key, but it stays in the type.
Any INVALID_* code, such as INVALID_OBJECT, INVALID_OBJECT_NAME or INVALID_RULE_PREFIX. Rule errors carry the offending prefix in error.extra.
UNKNOWN_ERROR: the response had no error code (see above).
BlobErrorCode also accepts any other string, so a code the service adds later still type-checks.

Retry policy

The SDK only retries what is safe to repeat: GET calls and multipart upload parts (each part number can be sent again). A retryable call is retried on:
  • a network error (including a body cut off mid-read);
  • any 5xx response;
  • TOO_MANY_CONCURRENT_CHUNKS on a multipart part: the server refuses the part before reading it, so it is sent again within the same budget.
It is never retried on any other 4xx, including 429. RATE_LIMITED can be an account block that lasts about 30 minutes, so the SDK leaves the decision to you.

Backoff

Before retry n (starting at 0), the SDK waits:
That is, exponential backoff capped at 8 seconds, with jitter between 50 % and 100 % of the delay. With the default maxRetries: 2, a call makes at most 3 attempts.

Storage outages

503 STORAGE_UNAVAILABLE means storage is briefly unreachable: the service refuses object calls in windows of about 10 seconds.
  • Reads and multipart parts retry it within maxRetries, which may not outlast the window: the default 2 retries take under 2 seconds.
  • Every other call gets a single attempt.
  • When it still fails, try again after about 10 seconds.
  • A multipart upload refused this way when it completes is aborted, like any other failure: run the whole put() again.

Retrying writes yourself

A write that fails with a network error or a 5xx may or may not have been applied. Retry it only when repeating it is safe for you, for example a put() to the same name with overwrite: true.
Do not retry 429 RATE_LIMITED in a tight loop: going over the account-wide budget can block the account for about 30 minutes. See the Blob API errors reference.

Timeouts

There is no client timeout and no way to cancel a call: a request lasts as long as fetch waits.

Next steps

Blob API errors reference

Every Blob error code, with its HTTP status.

Client

Credentials and client options.