> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors and retries

> Handle errors and retries in the Node.js SDK.

## Errors

If a call fails, the SDK throws one of these errors:

| Error | When the SDK throws it |
| - | - |
| `InfisicalSDKRequestError` | Infisical returned an error response. The error's `statusCode` holds the [HTTP status code](https://infisical.com/docs/api-reference/overview/errors.md#common-status-codes), and its `message` includes Infisical's description of the error. |
| `InfisicalSDKError` | The request failed for any other reason, such as a timeout, a network error, or an error response without a description of the error |

This example creates a secret if it doesn't exist yet:

```typescript theme={"dark"}
import { InfisicalSDKRequestError } from "@infisical/sdk";

try {
  await client.secrets().getSecret({
    projectId: "<project-id>",
    environment: "dev",
    secretName: "SESSION_KEY",
  });
} catch (err) {
  if (!(err instanceof InfisicalSDKRequestError) || err.statusCode !== 404) throw err;

  await client.secrets().createSecret("SESSION_KEY", {
    projectId: "<project-id>",
    environment: "dev",
    secretValue: "<new-session-key>",
  });
}
```

## Retries and timeouts

If Infisical [rate-limits](https://infisical.com/docs/api-reference/overview/rate-limits.md) a request, or the request fails with a network error or times out, the SDK retries the request up to four times. It waits about one second before the first retry and doubles the wait before each retry after that. If a request creates or deletes something in Agent Vault, the SDK retries it after a network error only if the request never reached Infisical, so a retry can't make the change twice.

Each request times out after 10 seconds. You can't change the timeout or the number of retries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.