feat(audience-sdk): SDK-257 E2E robustness follow-up#717
Merged
ImmutableJeffrey merged 1 commit intomainfrom Apr 30, 2026
Merged
feat(audience-sdk): SDK-257 E2E robustness follow-up#717ImmutableJeffrey merged 1 commit intomainfrom
ImmutableJeffrey merged 1 commit intomainfrom
Conversation
d3771d7 to
c682b6b
Compare
nattb8
approved these changes
Apr 30, 2026
…DK-257) Tests: - ThreadSafetyStressTests: 4 / 16 thread sustained Track load (5s, no exceptions, queue count matches fired). 16-thread mixed Track / Identify / SetConsent. 10 000-call per-call main-thread allocation budget via GC.GetAllocatedBytesForCurrentThread, isolated from drain-thread noise. - OfflineResilienceTests: Track and Shutdown absorb disk-write IOException without throwing. Memory-only fallback (retain events without losing in-flight) captured as [Ignore]'d test — EventQueue currently drops on IOException; gap documented for follow-up. - PublishableKeyPrefixTests: Init warns on test-prefix + production BaseUrl (and the symmetric pairing). Custom dev/staging URLs not flagged. Track + Flush surfaces backend 401 as ValidationRejected via OnError, body propagated through. - TimerDisposalTests: null, already-disposed, idle, long-running callback (regression guard for the SDK fix below). SDK: - ImmutableAudience.WarnIfKeyEnvironmentMismatch logs at Init when prefix and BaseUrl override contradict. Init proceeds either way. - New TimerDisposal.DisposeAndWait at three call sites (Session.Start, Session.DrainHeartbeatTimer, ImmutableAudience.Shutdown). Replaces a pattern that raced its own dispose — WaitOne timeout disposed the handle, then Timer's signal-when-done fired SetEvent on the closed SafeWaitHandle and crashed the threadpool. Helper leaks the wait handle on timeout; GC reclaims after the signal lands. Test infrastructure: - TestDefaults shared constants (FlushIntervalSeconds, FlushSize) across the new fixtures. Out of scope: - Kill-Unity restart automation — needs CLI Unity test harness. - Network toggle — platform-coupled, requires admin privileges. - EventQueue memory-only fallback for disk-full — separate ticket. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
c682b6b to
14cda32
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TimerDisposal.DisposeAndWaithelper; replaces ad-hocTimer.Dispose(WaitHandle) + usingpatterns inSession.Start,Session.DrainHeartbeatTimer, andImmutableAudience.Shutdown. Leaks the wait handle on timeout to avoid a threadpool crash on the underlying race.BaseUrlmismatch detection atInittime; logs a warning on test-key + production-BaseUrlpairings and vice versa.Trackload, mixedTrack/Identify/SetConsentconcurrency, main-thread allocation budget check.[Ignore]'dTrack_DiskWritesBlocked_RetainsEventsInMemory_AndSurfacesOnErrordocuments the deferredEventQueuememory-only fallback follow-up.TimerDisposalunit tests.Linear: SDK-257