FlagsmithClient should support deterministic shutdown of local-evaluation polling

Aperta
#191 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
csharp
Ambito
api

Direzione di ricerca

Inizia leggendo FlagsmithClient.cs e PollingManager.cs, concentrandoti sul finalizer, sul timer di polling, sul callback e sull’attuale cleanup di StopPoll. Implementa uno shutdown deterministico e idempotente che interrompa il polling, impedisca le richieste future, gestisca quando possibile i refresh in corso e preservi la sicurezza del finalizer; verifica il comportamento rispetto alla riproduzione descritta nell’issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
C#
Stelle
20
Fork
17
Merge medio
21h 47m
PR unite (30g)
8

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Flagsmith/flagsmith-dotnet-client

Tutte le issue di Flagsmith/flagsmith-dotnet-client

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.