fix: Clean up BatchUploader timers and event listeners on re-init#1251
fix: Clean up BatchUploader timers and event listeners on re-init#1251rmi22186 merged 3 commits intodevelopmentfrom
Conversation
PR SummaryLow Risk Overview SDK re-initialization now explicitly calls Reviewed by Cursor Bugbot for commit fee2cc7. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 50239ed. Configure here.
Prevents leaked timers and event listeners from accumulating across Jest test runs in batchUploader.spec.ts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a `destroyed` flag to prevent prepareAndUpload from rescheduling a new timer via triggerUploadInterval if destroy() was called while an upload was in-flight. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
# [2.65.0](v2.64.1...v2.65.0) (2026-04-23) ### Bug Fixes * Clean up BatchUploader timers and event listeners on re-init ([#1251](#1251)) ([79ca4f8](79ca4f8)) * honor config.domain when directURLRouting is enabled ([#1253](#1253)) ([8b64e8e](8b64e8e)) ### Features * set $NoTargeting as User Attribute value ([#1247](#1247)) ([6fa48bf](6fa48bf))
|
🎉 This PR is included in version 2.65.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |




Summary
BatchUploaderthat caused flaky test failuressetTimeoutID and event handler references as instance properties so they can be cleaned updestroy()method toBatchUploaderthat clears timers and removes event listenersdestroy()before re-init incompleteSDKInitialization()and in testbeforeEachteardownProblem
Each SDK re-initialization (and each test run) was leaking:
setTimeoutfromqueueUpload()that could fire during a later testvisibilitychange,beforeunload, andpagehidelisteners that accumulated with every initThis caused non-deterministic test failures depending on timer timing and listener execution order.