sodcalculator

10 Tech How-To

Verify Node.js Feature Flag Rollback Reached the App

Guide 10-38411 · Updated · Step by step

This guide shows you how to confirm that a feature flag rollback has actually taken effect in your Node.js application. You’ll learn several practical methods—from checking logs and metrics to querying the flag service directly—so you can be certain the old behavior is restored and users are no longer seeing the flagged feature.

What You’ll Need

  • Access to your Node.js application logs (e.g., stdout, log files, or a log aggregator).
  • Access to the feature flag service dashboard or API (e.g., LaunchDarkly, Flagsmith, or a custom service).
  • Basic familiarity with curl or a similar HTTP client for API calls.
  • If your app uses a metrics system (Prometheus, StatsD, etc.), access to query it.

Step-by-Step

  1. Check the feature flag service status.
    Log into your flag service dashboard and confirm the flag is set to the rolled-back value. If you have a REST API, you can query it directly, e.g., curl https://flags.example.com/flags/my-feature. Ensure the response shows the intended value (e.g., "on": false).
  2. Verify the app is using the latest flag configuration.
    Most SDKs cache flags locally and poll for updates. Check your app’s logs for a message like “Flag updated” or “Flag my-feature changed to false”. If you don’t see it, the SDK may not have received the change yet—wait for the next polling interval or restart the app if needed.
  3. Inspect real-time logs for feature-specific activity.
    Search your logs for any log lines that indicate the feature branch is executing. For example, if your code logs “Feature enabled” when the flag is true, look for the absence of that log after the rollback. Conversely, look for logs like “Feature disabled” that appear when the flag is false.
  4. Check metrics that track feature usage.
    If you instrument your code with counters or histograms tied to the feature, query your metrics system. A drop in the “feature_used” counter after the rollback time indicates the flag is no longer active.
  5. Perform a manual test against a test environment.
    If possible, hit an endpoint that depends on the flag and verify the response matches the rolled-back behavior. For example, if the flag controls a new checkout flow, confirm the old checkout flow appears.
  6. Use a debug endpoint in your app (if available).
    Some apps expose a /debug/flags endpoint that shows current flag values. If yours does, call it and verify the flag value is as expected.
  7. Check the SDK’s internal state.
    In your Node.js code, you can log the result of flagClient.variation('my-feature', user, false) directly. Add a temporary log line (or use a one-off script) to print the current value. If it returns false, the rollback has reached the app.
  8. Confirm the change propagated across all instances.
    If you run multiple Node.js processes or pods, repeat the above checks on each instance. You can also check the flag service’s “last updated” timestamp and compare it to your app’s logs to ensure all instances have received the update.

Common Mistakes

  • Assuming the flag service update is immediate. SDKs poll at intervals (e.g., 30 seconds), so there may be a delay. Always wait for the next poll or force a refresh.
  • Checking only the flag service dashboard. The dashboard shows the intended state, but the app may still have a cached old value. Always verify on the app side.
  • Forgetting about caching layers. If your app caches flag values in memory or Redis, the rollback may not take effect until the cache is invalidated.
  • Not checking all instances. In a distributed setup, one instance may have updated while another hasn’t. Always verify across all running processes.
  • Confusing the flag key name. Typos in the flag key can lead to checking the wrong flag. Double-check the exact key used in your code.

Tips

  • Add a startup log that prints all flag values. This gives you a baseline to compare against.
  • Use structured logging. Log flag changes with a consistent field like flag_name and flag_value so you can search easily.
  • Set up an alert on flag changes. Many flag services can send webhooks or notifications when a flag changes, so you know when to expect the app to update.
  • Incorporate a flag check into your health check endpoint. Return the current flag values in a /health response for quick inspection.
  • Consider using a local file as a fallback. If the flag service is unreachable, have your app read from a local JSON file that you can update manually during incidents.

Troubleshooting

If the rollback hasn’t reached the app, try the following in order:

  • Wait for the SDK’s polling interval. Check your SDK’s default poll time (often 30 seconds) and wait at least that long before investigating further.
  • Force a refresh. Many SDKs allow you to manually trigger a flag refresh. For example, in LaunchDarkly, you can call flagClient.identify() or use the SDK’s flush() method.
  • Restart the application. A restart clears any in-memory cache and forces a fresh fetch from the flag service.
  • Check network connectivity. Ensure your app can reach the flag service. Look for network errors in your logs or use a simple curl from the app’s host to test connectivity.
  • Verify the flag key and environment. Make sure you’re rolling back the correct flag and that the app is using the same environment (e.g., production vs. staging) as the one you modified.
  • Look for SDK errors. If the SDK fails to fetch flags, it may fall back to a default value. Check your logs for errors like “Failed to fetch flags” and fix the underlying issue.
  • Check if the flag is overridden by a user or context. If your flag is targeted to specific users or groups, the rollback may not affect those who are explicitly targeted. Review the targeting rules.

Frequently Asked Questions

Why is my app still showing the feature after I rolled back the flag?

Most likely the SDK hasn’t polled yet, or the app is caching the old value. Wait for the polling interval, or restart the app to force a refresh.

How long does it take for a rollback to reach my Node.js app?

It depends on the SDK’s polling interval, typically 30 seconds to 5 minutes. Some SDKs also support streaming updates that are near-instant. Check your SDK’s configuration.

Can I verify the rollback without changing my code?

Yes, you can use a debug endpoint if you have one, or query the flag service API to see the intended value. However, to confirm the app is actually using the new value, you’ll need to check logs or metrics that reflect the app’s behavior.

What if my app has multiple instances and only some updated?

This can happen if instances poll at different times or if some are behind a load balancer that caches responses. Check each instance individually, and consider using a streaming flag service that pushes updates immediately.

Is it safe to rely on the flag service dashboard alone?

No, the dashboard shows the desired state, not what the app is actually using. Always verify on the app side to avoid surprises.

What should I do if the flag service is down during a rollback?

If the flag service is down, your app may use cached values or fall back to defaults. In such cases, you might need to manually update a local config file or restart the app with environment variables to force the rollback.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →