Skip to content

fix: only attach $sdk_debug_pending_queue_size once the queue reaches flushAt - #736

Merged
marandaneto merged 2 commits into
mainfrom
fix/queue-size-debug-only-when-degraded
Nov 20, 2026
Merged

marandaneto merged 2 commits into
mainfrom
fix/queue-size-debug-only-when-degraded

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

On Windows and Linux, the Dart core adds $sdk_debug_pending_queue_size to every event, even when the queue holds fewer events than flushAt. That is just normal batching, so the value adds bytes to every event without helping anyone find a delivery problem. iOS, macOS, Android and web events come from the native SDKs and posthog-js, which make the same change in their own PRs.

Now the key is only attached once the queue holds at least flushAt events. The key stays SDK-owned. While the queue is healthy, a registered or caller-supplied value with the same name is left out of the event. When the queue is backed up, the SDK value replaces it, as before.

This touches the same _sessionDebugProperties block as #733, which removes the session keys. Whichever lands second needs a small merge.

Spec: PostHog/sdk-specs#238.

💚 How did you test it?

  • New posthog_core_test.dart case: no key below flushAt, including registered and caller values, and the depth at flushAt. It failed before the change.
  • flutter test passes (1327 tests). dart format and flutter analyze are clean.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

@github-actions

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-11-20 08:51:38 UTC
Duration: 96583ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 128ms
Format Validation.Event Has Uuid ✅ 116ms
Format Validation.Event Has Lib Properties ✅ 113ms
Format Validation.Distinct Id Is String ✅ 113ms
Format Validation.Token Is Present ✅ 115ms
Format Validation.Custom Properties Preserved ✅ 113ms
Format Validation.Event Has Timestamp ✅ 113ms
Retry Behavior.Retries On 503 ✅ 5327ms
Retry Behavior.Does Not Retry On 400 ✅ 2115ms
Retry Behavior.Does Not Retry On 401 ✅ 2115ms
Retry Behavior.Respects Retry After Header ✅ 8123ms
Retry Behavior.Implements Backoff ✅ 15439ms
Retry Behavior.Retries On 500 ✅ 5223ms
Retry Behavior.Retries On 502 ✅ 5223ms
Retry Behavior.Retries On 504 ✅ 5223ms
Retry Behavior.Max Retries Respected ✅ 15443ms
Deduplication.Generates Unique Uuids ✅ 120ms
Deduplication.Preserves Uuid On Retry ✅ 5222ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10324ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5227ms
Deduplication.No Duplicate Events In Batch ✅ 120ms
Deduplication.Different Events Have Different Uuids ✅ 114ms
Compression.Sends Gzip When Enabled ✅ 115ms
Batch Format.Uses Proper Batch Structure ✅ 112ms
Batch Format.Flush With No Events Sends Nothing ✅ 108ms
Batch Format.Multiple Events Batched Together ✅ 119ms
Error Handling.Does Not Retry On 403 ✅ 2114ms
Error Handling.Does Not Retry On 413 ✅ 2116ms
Error Handling.Retries On 408 ✅ 5223ms

Feature_Flags Tests

✅ 16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 12ms
Request Payload.Flags Request Uses V2 Query Param ✅ 7ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 7ms
Request Payload.Flags Request Omits Authorization Header ✅ 8ms
Request Payload.Token In Flags Body Matches Init ✅ 6ms
Request Payload.Groups Round Trip ✅ 7ms
Request Payload.Groups Default To Empty Object ✅ 8ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It ✅ 6ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 7ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 7ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 7ms
Request Lifecycle.No Flags Request On Init Alone ✅ 2ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 110ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 13ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 7ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 112ms

@marandaneto
marandaneto marked this pull request as ready for review November 20, 2026 08:56
@marandaneto
marandaneto requested a review from a team as a code owner November 20, 2026 08:56
@veria-ai

veria-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@ioannisj ioannisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 An AI agent wrote this on behalf of @ioannisj.

No findings from me. I looked at the queue-size gate against PostHog/sdk-specs#238 and at the 413 path, which only shrinks _maxBatchSize, so flushAt stays the right threshold.

@marandaneto
marandaneto merged commit 34144cb into main Nov 20, 2026
30 checks passed
@marandaneto
marandaneto deleted the fix/queue-size-debug-only-when-degraded branch November 20, 2026 12:57
turnipdabeets added a commit that referenced this pull request Nov 20, 2026
Conflicts: #736's backedUpQueueLength reads the analytics lane's flushAt,
since 6.0 replaced the single _flushAt with per-lane capture v1 queues; the
HTTP client keeps its connection timeout. #736's test asserted that SDK debug
values win over registered and caller properties, which 6.0 reverses (see
"Check property precedence" in MIGRATION.md), so the ported test checks the
flushAt threshold and keeps 6.0's precedence.
@turnipdabeets turnipdabeets mentioned this pull request Nov 20, 2026
12 of 18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants