FlagsmithClient should support deterministic shutdown of local-evaluation polling

Abierto
#191 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
csharp
Área
api

Línea de trabajo

Comienza leyendo FlagsmithClient.cs y PollingManager.cs, centrándote en el finalizador, el temporizador de polling, el callback y la limpieza actual de StopPoll. Implementa un apagado determinista e idempotente que detenga el polling, impida solicitudes futuras, gestione los refreshes en curso cuando sea posible y preserve la seguridad del finalizador; verifica el comportamiento con la reproducción descrita en el issue.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Problem

In Flagsmith .NET SDK 9.0.0, enabling local evaluation starts a PollingManager backed by System.Threading.Timer.

The only cleanup currently occurs in the FlagsmithClient finalizer:

~FlagsmithClient() => _pollingManager?.StopPoll();

This does not provide deterministic cleanup when an application host or dependency-injection container stops. Additionally, the timer callback retains the polling manager, whose callback retains the client. This may keep the client reachable and prevent its finalizer from running.

Relevant source:

Impact

In long-running processes that create and stop application hosts:

  • Environment-document requests can continue after the host stops.
  • Recreated hosts and tests can accumulate polling timers.
  • References to clients, loggers, and related services can remain alive.
  • Consumers cannot bind polling cleanup to their application lifecycle.

Process termination masks the issue because the operating system removes the timer.

Reproduction

  • Configure FlagsmithClient with local evaluation and a short refresh interval.
  • Point it at an HTTP handler that counts environment-document requests.
  • Create the client and observe polling.
  • Stop or dispose the owning host or service provider without terminating the process.
  • Wait beyond the refresh interval.
  • Environment-document requests continue because there is no public shutdown or disposal API.

Expected behaviour

FlagsmithClient should expose deterministic cleanup, for example through IDisposable, IAsyncDisposable, or an explicit shutdown method.

Cleanup should:

  • Stop and dispose the polling timer immediately.
  • Prevent future environment-document requests.
  • Cancel an in-flight refresh where possible.
  • Be idempotent.
  • Call GC.SuppressFinalize if a finalizer remains as a fallback.

This would allow integrations such as OpenFeature providers to stop polling from their normal host shutdown lifecycle.

Lenguaje dominante
C#
Estrellas
20
Forks
17
Merge medio
21 h 47 min
PR fusionados (30 d)
8

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Flagsmith/flagsmith-dotnet-client

Todos los issues de Flagsmith/flagsmith-dotnet-client

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.