# Detecting and aborting hanging Steps

You can detect and abort hanging Steps that do not produce any log output for a certain amount of time using the **No Output Timeout** function. You can use this function to automatically abort hung builds after a configurable timeout period to save credits and to enable Bitrise to gather data on hanging builds.

You can use the **No Output Timeout** function in two ways:

- [Enable globally for all Steps](#enabling-the-no-output-timeout-function-globally-for-all-steps).
- [Enable for specific Steps only](#enabling-the-no-output-timeout-function-for-specific-steps).

The **No Output Timeout** function can be used alongside other timeout functionalities, such as the one described in the [M1 Hanging builds issue guide](https://devcenter.bitrise.io/en/infrastructure/build-stacks/apple-silicon-m1-stacks.html#hanging-builds-issue) or in [Setting a time limit for Steps](/bitrise-ci/workflows-and-pipelines/steps/setting-a-time-limit-for-steps).

## Enabling the No Output Timeout function globally for all Steps

:::important[Bitrise 1.50.0 or newer is required]

You must use Bitrise 1.50.0 or a newer version to use the **No Output Timeout** function.

:::

To enable the **No Output Timeout** globally for all Steps:

1. 1. Log in to Bitrise and select **Bitrise CI** on the left, then select your project.
1. Click the **Workflows** button on the main page.
1. Go to the **Secrets** tab.
1. Add a new secret Env Var: `BITRISE_NO_OUTPUT_TIMEOUT` and set its value to the number of seconds you want the build to wait for output logs before aborting.

   We recommend setting it to 600 seconds (10 minutes).

   ![app-level-secret.png](/img/_paligo/uuid-7d34c319-a1a2-05a1-90b0-ded10c048482.png)

   :::note[Aborting a hanging build automatically]

   Compared to [setting a time limit for Steps](/bitrise-ci/workflows-and-pipelines/steps/setting-a-time-limit-for-steps), the **No Output Timeout** function only aborts a build if no output log is generated for a set amount of time.

   Any log output will reset the timeout. This can result in a Step running longer than the value you set in `BITRISE_NO_OUTPUT_TIMEOUT`.

   :::
1. Select **Expose for pull requests**.

   :::important[Pull request builds need the Secret exposed]

   Secrets are not available in pull request builds unless you expose them. Without this, the **No Output Timeout** function silently does not apply to pull request builds. The value is not sensitive, so exposing it is safe. For details, see [Exposing a Secret to pull requests](/bitrise-ci/configure-builds/secrets#exposing-a-secret-to-pull-requests).

   If you can't expose the Secret to pull requests, for example, because your app is public, [enable the function for specific Steps](#enabling-the-no-output-timeout-function-for-specific-steps) instead.

   :::
1. Click **Save**. You can check the Build log of your build to determine if the function is enabled.

   ![step-force-output.png](/img/_paligo/uuid-dc3bfafa-9720-8935-557a-97c317a8a624.png)

And that's it! From now on, whenever a Step does not produce an output log for the number of seconds you set in `BITRISE_NO_OUTPUT_TIMEOUT`, your build automatically aborts with the message: `Abort via Bitrise CLI (no output timeout)`.

:::tip[Disabling the No Output Timeout function for a specific Step]

If you enabled the **No Output Timeout** function globally and want to disable it for specific Steps, you can add the `no_output_timeout: 0` Step property just above the `inputs:` part of the chosen Step(s) in the `bitrise.yml`.

For example:

```yaml
steps:    
    - virtual-device-testing-for-ios@1:
        no_output_timeout: 0
        inputs:
        - zip_path: "$BITRISE_PROJECT_PATH"
```

:::

## Enabling the No Output Timeout function for specific Steps

:::important[Bitrise 1.50.0 or newer is required]

You must use Bitrise 1.50.0 or a newer version to use the **No Output Timeout** function.

:::

You can enable the **No Output Timeout** function for specific Steps by adding the `no_output_timeout` Step property below a Step in your bitrise.yml file.

To do so with the Workflow Editor:

1. 1. Log in to Bitrise and select **Bitrise CI** on the left, then select your project.
1. Click the **Workflows** button on the main page.
1. Go to the **bitrise.yml** tab.
1. Search for the Step(s) where you would like to use the function.
1. Insert `no_output_timeout: 12` Step property and value just above the `inputs:` part of the chosen Step(s) to automatically abort a build if the Step does not produce an output log for 12 seconds.

   :::tip[Setting the `no_output_timeout` Step property to 0]

   You can disable the **No Output Timeout** function for a Step by setting the `no_output_timeout` Step property to 0.

   :::

   Let's look at an example where a Script Step will always be aborted automatically:

   ```ruby
   output_slows_down:
       steps:
       - script@1:
           title: Output is slower and slower
           no_output_timeout: 12
           inputs:
           - content: |-
               #!/usr/bin/env bash
               for i in {1..5}
               do
                 DURATION=$((5*i))
                 echo "🏃‍step output (sleeping ${DURATION}s)"
                 sleep $DURATION
               done
   ```

And that's it! Now, if your Step hangs and does not produce a single output log for the number of seconds you specified in the `no_output_timeout` Step property, the build will be aborted automatically.
