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

# BackgroundStatus

# BackgroundStatus

The return type of `controller.backgroundStatus()` from [`initLatestDeployment()`](https://www.adaline.ai/docs/reference/sdk/v2/typescript/classes/adaline#initlatestdeployment). Provides health information about the background polling loop that keeps a deployment up to date.

## Definition

```typescript theme={null}
interface BackgroundStatus {
  stopped: boolean;
  consecutiveFailures: number;
  lastError: Error | null;
  lastRefreshed: Date;
}
```

***

## Fields

| Field | Type | Description |
| - | - | - |
| `stopped` | `boolean` | `true` if the background polling loop has been stopped (either manually via `controller.stop()` or due to unrecoverable errors). |
| `consecutiveFailures` | `number` | The number of consecutive refresh failures since the last successful poll. Resets to `0` on a successful refresh. |
| `lastError` | `Error \| null` | The most recent error encountered during polling, or `null` if the last refresh succeeded. |
| `lastRefreshed` | `Date` | Timestamp of the last successful deployment refresh. |

***

## Usage

```typescript theme={null}
import { Adaline } from '@adaline/client';

const adaline = new Adaline();

const controller = await adaline.initLatestDeployment({
  promptId: 'prompt_abc123',
  deploymentEnvironmentId: 'environment_abc123',
});

// Check the health of background polling
const status = controller.backgroundStatus();

console.log(`Stopped: ${status.stopped}`);
console.log(`Consecutive failures: ${status.consecutiveFailures}`);
console.log(`Last error: ${status.lastError?.message ?? 'none'}`);
console.log(`Last refreshed: ${status.lastRefreshed.toISOString()}`);
```

### Health monitoring

Use `backgroundStatus()` in a periodic health check to detect degraded state:

```typescript theme={null}
setInterval(() => {
  const status = controller.backgroundStatus();

  if (status.stopped) {
    console.error('Background refresh stopped — deployments are stale');
  } else if (status.consecutiveFailures > 3) {
    console.warn(
      `Deployment refresh degraded: ${status.consecutiveFailures} consecutive failures. ` +
      `Last error: ${status.lastError?.message}`
    );
  }
}, 30_000);
```

***

## See Also

* [Adaline](https://www.adaline.ai/docs/reference/sdk/v2/typescript/classes/adaline.md) — `initLatestDeployment()` returns the controller that exposes this type


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