Skip to main content

Kill Switch

A kill switch is a feature flag used as an emergency circuit breaker. When something goes wrong in production, disable the flag and the feature turns off instantly. No code change, no deploy.

Pattern

Wrap any risky feature path in a flag check. If the flag is off, fall back to the safe path:

const flags = await evaluate(user);

if (flags['new_payment_processor']?.enabled) {
await processWithNewProvider(order);
} else {
await processWithLegacyProvider(order);
}

When the new payment processor starts throwing errors, disable the flag. Traffic immediately returns to the legacy path.

Setting up a kill switch flag

In the dashboard:

  1. Open your project and select the Production environment
  2. Enter a flag name (e.g. New Payment Processor) and a key (e.g. new_payment_processor), then click Add flag
  3. Click the toggle to enable the flag

The flag is now live for all users. Your application can start evaluating it.

Triggering the switch

When you need to kill the feature, open the dashboard:

  1. Go to the production environment flags list
  2. Click the toggle next to the flag to disable it

The change takes effect on the next evaluation call — within seconds for most applications.

If you prefer the API:

curl -X PUT https://api.ffs.adarshrust.com/api/projects/$PROJECT_ID/environments/$ENV_ID/flags/$FLAG_ID \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ "enabled": false }'

Re-enabling

Click the toggle again when the underlying issue is resolved. The flag comes back on for all users immediately.

A note on rollout percentage

The global enabled toggle overrides everything — rules and rollout alike. Setting rollout to 0% does not disable the flag. When the flag is enabled with rollout at 0, it evaluates to true for all users. The toggle (which flips the enabled field) is the correct kill switch — not the rollout percentage.

Add it to your runbooks

Kill switches are only useful if your team knows they exist and knows how to use them under pressure. Add a section to your incident runbooks:

If [service X] is degraded:
1. Log in to ffs.adarshrust.com
2. Go to [project] → Production
3. Click the toggle to disable the [flag name] flag
4. Confirm the error rate drops