redis/node-redis · warning · Error

TokenManager is not running but received an error: ${errorMe

Error message

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

What it means

notifyError() is called when a token refresh fails and (after classification) must deliver an IDPError to the listener. It guards that a listener still exists; if the manager was stopped between the failed request and this call, there is nowhere to deliver the error and the manager throws instead of silently swallowing it. The message embeds the underlying errorMessage for diagnosability.

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 bb5beb5657)

Solutions

  1. Treat this as a teardown-race signal: ensure in-flight requests are drained or their rejections ignored during dispose().
  2. Do not act on the error (it is informational); the manager is already stopped.
  3. If it surfaces in production outside shutdown, review the IDP error-handling path and report a lifecycle bug with the interleaving.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  // ... token refresh path
} catch (err) {
  if (err instanceof Error && /not running but received an error/.test(err.message)) {
    // error arrived after dispose; informational only
  } else throw err;
}

Prevention

When it happens

Trigger: The identity provider rejects a request, the retry path or non-retryable path reaches notifyError, but dispose() ran in the meantime and nulled the listener; a fatal IDP error triggers stop() and a concurrent in-flight request then also fails and calls notifyError on the already-stopped manager.

Common situations: IDP outage during shutdown; cascading failures where the first error stops the manager and subsequent in-flight requests also fail; tests forcing IDP errors then immediately disposing.

Related errors


AI-assisted analysis of redis/node-redis@bb5beb5657 (2026-08-03). Data as JSON: /data/errors/645e2f05c8eb935e.json. Report an issue: GitHub.