> For the complete documentation index, see [llms.txt](https://docs.conanjs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.conanjs.io/data/conan-state/life-cycle/introspection.md).

# Introspection

## Introduction

ConanJs gives you the ability to check on its internal status so that you can leverage this information for common use cases. For instance:

* You can check if there has been an error and [handle it anyway you prefer](broken://pages/-M9U43o_b-Vt7S9to1yk).
* You can check if there are operations running at the moment, and wait for them to finish, [very handy for testing](/data/conan-state/testing.md).
* You can also test for the state to be [stopped / started](broken://pages/-MBmtP5NHJQKJIXkc0rZ) so you can react accordingly.

## The Meta Flow Statuses

These are the different statuses in the meta flow:

* **starting**. The Conan State is starting
* **init**. The Conan State has started and reached the first initial state.
* **running**. The Conan State is running at least one action (sync or async)
* **idle.** The Conan State is started but is not running anything at the moment.
* **idleOnTransaction.** Similar, but on a transaction, while on a transaction, the idle status only is reached when the transaction is closed. This is very handy for [testing](/data/conan-state/testing.md)
* **error** An error has occurred

## The MetaInfo

The information for each status is encapsulated in a [MetaInfo](/api/conan-state-classes/metainfo.md) object, which has three properties:

* **lastError**: The last error raised
* **transactionCount:** The count of transactions opened at the moment.
* **status:** One of

```typescript
export enum MetaStatus {
    STARTING = 'STARTING',
    INIT = "INIT",
    RUNNING = "RUNNING",
    ERROR = "ERROR",
    IDLE = "IDLE",
    IDLE_ON_TRANSACTION = "IDLE_ON_TRANSACTION",
}
```

## Transactions

Is possible to open a transaction for a [ConanState](/api/main-classes/conan-state.md)

```typescript
numberValue$.openTransaction(`test-transaction`)
```

�When you open a transaction, the IDLE state will only be reached if all actions (sync and async) are fulfilled and the transaction is closed

```typescript
numberValue$.closeTransaction()
```

{% hint style="success" %}
As of v1.0 transactions don't really honour their name, ie, they only let you group actions to know when they complete, which we think is very useful for [testing](/data/conan-state/testing.md)

In future releases we are hoping for transactions to be much powerful and let you perform operations like rollbacks / commits...

Stay tuned!
{% endhint %}

![Working hard on the next version!](/files/-MC6e2LYVlVH5tpWHUFc)

## Accessing the Meta Flow

In every [Conan State](/data/conan-state.md), you have a property to retrieve the meta Flow

```typescript
numberValue$.metaFlow
```

You can check our [Conan Flows](/data/flows.md) docs to see how you can normally access the different statuses.

We do have dedicated sections for [error handling](broken://pages/-M9U43o_b-Vt7S9to1yk) and [testing state](/data/conan-state/testing.md) which are heavily connected to the Meta Flow

### Stop / Start

ConanState objects can be *stopped* and *started* on demand. At the moment they always start up *started*.

{% hint style="success" %}
Stopping / Starting Conan State can be useful if you need to work with streams of data or other similar use cases.

At the moment this is not something that you are going to fully leverage as our APIs need to be matured.
{% endhint %}

### Error Handling

A particular use case to access the meta flow is to handle errors, every time an exception is thrown in your code, it is caught and the monitor is updated to reflect this.

This is handy if you want to then add a toast message or something similar.

{% hint style="success" %}
We see error handling to be associated with the transactions, as mentioned above, this is something where we are expecting to provide with more features in the next releases/
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.conanjs.io/data/conan-state/life-cycle/introspection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
