redis/node-redis · warning · Error

TokenManager is not running but received an error

Error message

TokenManager is not running but received an error: ${errorMessage}

What it means

The error-path twin of error 7. notifyError delivers an IDP error to listener.onError; when the listener is null (manager stopped) it throws instead. Triggered when an in-flight requestToken() rejects after stop() has cleared the listener.

Solutions

  1. Await in-flight refresh before stop().
  2. Catch and log this specific error during teardown.
  3. Make stop() cancel pending token requests rather than letting them resolve later.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await manager.refresh();
} catch (err) {
  if (/not running.*error/i.test(err.message)) {
    // teardown race; safe to ignore
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: stop() called while requestToken() is pending; the request later rejects (network/credentials) and the rejection surfaces through notifyError with no listener attached.

Common situations: Teardown during an IDP outage; IDP rejecting concurrently with shutdown; retry timer firing after stop.

Related errors


AI-assisted analysis of redis/node-redis@90fd0652bc (2026-08-11). Data as JSON: /api/errors/645e2f05c8eb935e. Report an issue: GitHub.

Appendix: source

Thrown at packages/client/lib/authx/token-manager.ts:314

    }

    this.listener = null;
    this.currentToken = null;
    this.retryAttempt = 0;
  }

  /**
   * Returns the current token or null if no token is available.
   */
  public getCurrentToken(): Token<T> | null {
    return this.currentToken;
  }

  private notifyError(error: unknown, isRetryable: boolean): void {
    const errorMessage = error instanceof Error ? error.message : String(error);

    if (!this.listener) {
      throw new Error(`TokenManager is not running but received an error: ${errorMessage}`);
    }

    this.listener.onError(new IDPError(errorMessage, isRetryable));
  }
}

View on GitHub (pinned to 90fd0652bc)