Skip to Content

Errors

What the Node.js SDK throws, how to tell errors apart, and how to retry.

Every SDK call returns a promise. When something goes wrong, the promise rejects with a VizblApiError, or with its subclass VizblImportError when an import fails while you wait for it. Two cases are different: several failed files in one importModel() call reject with an AggregateError, and a call you cancel with a signal rejects with that signal's reason.

What to do

SituationWhat you getWhat to do
No key: apiKey not passed and VIZBL_API_KEY emptynew Vizbl() throws, code is missing_api_keySet VIZBL_API_KEY or pass apiKey.
The key is wrong or deletedisAuthError() is true (401)Check the key, or create a new one.
The key may not do thisisForbidden() is true (403)Give the key the access it needs: see What a key may do.
The job or the object doesn't existisNotFound() is true (404)Check the jobId or the tinuuid.
Too many requestsisRateLimited() is true (429)Wait and retry.
The same idempotency key with a different requeststatusCode is 409The first import has started. See Retry an import safely.
The import failedVizblImportError, code is the job's error codeSee Import errors.
The import didn't finish within maxWaitMsVizblImportError, code is import_wait_timeoutRead the job later with objects.imports.get().
Uploading a file to storage failedcode is upload_failed, or statusCode is the status storage answered with and there is no codeCall importModel() again: nothing was imported yet.
The network failed, or an API request took longer than timeoutMsVizblApiError without statusCode or code; the original error is in causeRetry.
The SDK got invalid options, such as both file and variantsVizblApiError with an SDK code and no statusCodeFix the call.

Catch an error

Create the client inside the try too: a missing key throws from the constructor, before any request.

import Vizbl, { VizblApiError, VizblImportError } from '@vizbl/node';

try {
  const vizbl = new Vizbl();
  const object = await vizbl.objects.importModel({ file: './chair.glb', wait: true });
  console.log(object.tinuuid, object.url);
} catch (error) {
  if (error instanceof VizblImportError) {
    console.error('Import failed:', error.code, error.message);
  } else if (error instanceof VizblApiError && error.isAuthError()) {
    console.error('Check VIZBL_API_KEY');
  } else if (error instanceof VizblApiError) {
    console.error(error.statusCode, error.code, error.message);
  } else {
    throw error;
  }
}

VizblApiError

PropertyTypeMeaning
messagestringWhat went wrong, in words. Don't branch on it.
statusCodenumber | undefinedThe HTTP status, when the error came from a response.
codestring | undefinedAn error code from the SDK: see SDK error codes and Import errors.
detailsunknownThe error body of the API, or the import job for a VizblImportError.
responseResponse | undefinedThe HTTP response, when there was one.
Methodtrue when
isAuthError()statusCode is 401: the key is missing or wrong.
isForbidden()statusCode is 403: the key is valid but may not do this.
isNotFound()statusCode is 404.
isRateLimited()statusCode is 429.

The API's own error code, such as http_error.404, is not in code: it is in the error body, error.details.code. The Developer API errors describe that body.

Import errors

When you wait for an import, with wait in importModel() or with objects.imports.wait(), a job that fails throws a VizblImportError. It is a VizblApiError, so the checks above work on it too.

  • code is the job's error code, such as usdz_conversion_failed or render_failed, or import_wait_timeout if the job didn't finish within maxWaitMs.
  • details is the import job. Its jobId lets you read the job again with objects.imports.get().

A failed job usually means the 3D file could not be converted. Check that the file opens in a 3D viewer, then import it again.

Several files failed

importModel() reads, presigns and uploads variant files in parallel. If more than one file fails at any of these steps, it throws an AggregateError whose errors hold one error per failed file. Check each of them: two rate-limited uploads arrive as two errors inside one AggregateError, not as one VizblApiError.

SDK error codes

These codes come from the SDK itself, not from the API.

codeMeaning
missing_api_keyNo apiKey, and VIZBL_API_KEY is empty. Thrown by the constructor, with statusCode 401.
missing_import_fileNeither file nor variants was passed.
ambiguous_import_filesBoth file and variants were passed.
missing_import_nameNo name, and none can be taken from a file name.
invalid_model_filefile is not a path, a Buffer, a Uint8Array, an ArrayBuffer or a Blob.
missing_file_nameA file from memory came without fileName.
model_file_read_failedA local file could not be read.
invalid_upload_concurrencyuploadConcurrency is not a positive whole number.
upload_failedUploading a file to storage failed on the way, for example on a network error. If storage answers with an error status, the error has that statusCode and no code.
invalid_presign_response, invalid_import_job_response, invalid_import_resultThe API answered with something the SDK did not expect. Contact Vizbl support.
import_wait_timeoutA VizblImportError: the job didn't finish within maxWaitMs.

Retry

The SDK doesn't retry failed requests by itself.

Retry when the API is rate limiting you (429), when it fails on its side (5xx), or when the network failed. Wait longer after each attempt. A call you cancelled with a signal can look like a network failure, so don't retry a call you aborted. A request that starts an import is safe to repeat only with the same idempotency key and the same body, so retry objects.imports.create() rather than importModel(): see Retry an import safely.

import { VizblApiError } from '@vizbl/node';

function shouldRetry(error) {
  if (!(error instanceof VizblApiError)) return false;
  if (error.isRateLimited()) return true;
  if (error.statusCode !== undefined) return error.statusCode >= 500;
  return error.code === undefined; // the network failed or the request timed out
}

async function withRetry(request, attempts = 4) {
  for (let attempt = 1; ; attempt += 1) {
    try {
      return await request();
    } catch (error) {
      if (attempt === attempts || !shouldRetry(error)) throw error;
      await new Promise((resolve) => setTimeout(resolve, 1000 * 2 ** attempt));
    }
  }
}

const job = await withRetry(() =>
  vizbl.objects.imports.create(
    { name: 'Oak lounge chair', variants: [{ uploadId: upload.uploadId, name: 'Default' }] },
    { idempotencyKey: 'import-chair-2026-06-11' },
  ),
);

On this page