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
| Situation | What you get | What to do |
|---|---|---|
No key: apiKey not passed and VIZBL_API_KEY empty | new Vizbl() throws, code is missing_api_key | Set VIZBL_API_KEY or pass apiKey. |
| The key is wrong or deleted | isAuthError() is true (401) | Check the key, or create a new one. |
| The key may not do this | isForbidden() is true (403) | Give the key the access it needs: see What a key may do. |
| The job or the object doesn't exist | isNotFound() is true (404) | Check the jobId or the tinuuid. |
| Too many requests | isRateLimited() is true (429) | Wait and retry. |
| The same idempotency key with a different request | statusCode is 409 | The first import has started. See Retry an import safely. |
| The import failed | VizblImportError, code is the job's error code | See Import errors. |
The import didn't finish within maxWaitMs | VizblImportError, code is import_wait_timeout | Read the job later with objects.imports.get(). |
| Uploading a file to storage failed | code is upload_failed, or statusCode is the status storage answered with and there is no code | Call importModel() again: nothing was imported yet. |
The network failed, or an API request took longer than timeoutMs | VizblApiError without statusCode or code; the original error is in cause | Retry. |
The SDK got invalid options, such as both file and variants | VizblApiError with an SDK code and no statusCode | Fix 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
| Property | Type | Meaning |
|---|---|---|
message | string | What went wrong, in words. Don't branch on it. |
statusCode | number | undefined | The HTTP status, when the error came from a response. |
code | string | undefined | An error code from the SDK: see SDK error codes and Import errors. |
details | unknown | The error body of the API, or the import job for a VizblImportError. |
response | Response | undefined | The HTTP response, when there was one. |
| Method | true 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.
codeis the job's error code, such asusdz_conversion_failedorrender_failed, orimport_wait_timeoutif the job didn't finish withinmaxWaitMs.detailsis the import job. ItsjobIdlets you read the job again withobjects.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.
code | Meaning |
|---|---|
missing_api_key | No apiKey, and VIZBL_API_KEY is empty. Thrown by the constructor, with statusCode 401. |
missing_import_file | Neither file nor variants was passed. |
ambiguous_import_files | Both file and variants were passed. |
missing_import_name | No name, and none can be taken from a file name. |
invalid_model_file | file is not a path, a Buffer, a Uint8Array, an ArrayBuffer or a Blob. |
missing_file_name | A file from memory came without fileName. |
model_file_read_failed | A local file could not be read. |
invalid_upload_concurrency | uploadConcurrency is not a positive whole number. |
upload_failed | Uploading 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_result | The API answered with something the SDK did not expect. Contact Vizbl support. |
import_wait_timeout | A 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' },
),
);