FlagsmithClient should support deterministic shutdown of local-evaluation polling

Đang mở
#191 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu bằng cách đọc FlagsmithClient.cs và PollingManager.cs, tập trung vào finalizer, bộ hẹn giờ polling, callback và phần cleanup StopPoll hiện tại. Triển khai quy trình shutdown xác định và idempotent, trong đó dừng polling, ngăn các request trong tương lai, xử lý các refresh đang chạy khi có thể và duy trì tính an toàn của finalizer; xác minh hành vi dựa trên reproduction được mô tả trong issue.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
20
Fork
17
Merge trung bình
21 giờ 47 phút
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Flagsmith/flagsmith-dotnet-client

Tất cả issue của Flagsmith/flagsmith-dotnet-client

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.