From 35ba78b6b4f4bdff204f18f507a86f91efe5b992 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 24 Jun 2026 19:16:36 +0200 Subject: [PATCH 1/2] fix: Clear feature flag called cache on shutdown --- .changeset/quiet-cycles-shutdown.md | 5 +++++ lib/posthog/client.rb | 3 +++ spec/posthog/client_spec.rb | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 .changeset/quiet-cycles-shutdown.md diff --git a/.changeset/quiet-cycles-shutdown.md b/.changeset/quiet-cycles-shutdown.md new file mode 100644 index 0000000..1063d4a --- /dev/null +++ b/.changeset/quiet-cycles-shutdown.md @@ -0,0 +1,5 @@ +--- +"posthog-ruby": patch +--- + +Clear the feature flag call dedupe cache on shutdown. diff --git a/lib/posthog/client.rb b/lib/posthog/client.rb index 5f80feb..014badc 100644 --- a/lib/posthog/client.rb +++ b/lib/posthog/client.rb @@ -790,6 +790,9 @@ def shutdown @worker&.shutdown @worker_thread&.join(1) end + @distinct_id_has_sent_flag_calls_mutex.synchronize do + @distinct_id_has_sent_flag_calls.clear + end end private diff --git a/spec/posthog/client_spec.rb b/spec/posthog/client_spec.rb index 3a4a609..553f236 100644 --- a/spec/posthog/client_spec.rb +++ b/spec/posthog/client_spec.rb @@ -1534,6 +1534,14 @@ def run end describe '#shutdown' do + it 'clears feature flag call dedupe cache' do + client.instance_variable_get(:@distinct_id_has_sent_flag_calls)['user'] = ['flag_true'] + + client.shutdown + + expect(client.instance_variable_get(:@distinct_id_has_sent_flag_calls).length).to eq(0) + end + it 'is idempotent and stops accepting new events' do worker = instance_spy(PostHog::NoopWorker, is_requesting?: false) client.instance_variable_set(:@worker, worker) From 9b37ad0c81d874b4daf1d2a470459be5075d89de Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 24 Jun 2026 19:41:47 +0200 Subject: [PATCH 2/2] chore: release posthog-rails for shutdown fix --- .changeset/quiet-cycles-shutdown.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/quiet-cycles-shutdown.md b/.changeset/quiet-cycles-shutdown.md index 1063d4a..11c3120 100644 --- a/.changeset/quiet-cycles-shutdown.md +++ b/.changeset/quiet-cycles-shutdown.md @@ -1,5 +1,6 @@ --- "posthog-ruby": patch +"posthog-rails": patch --- Clear the feature flag call dedupe cache on shutdown.