fix(website): prevent duplicate startTracking causing rudderQueue error#2617
Open
tolzhabayev wants to merge 1 commit intomainfrom
Open
fix(website): prevent duplicate startTracking causing rudderQueue error#2617tolzhabayev wants to merge 1 commit intomainfrom
tolzhabayev wants to merge 1 commit intomainfrom
Conversation
Guard startTracking with a module-level initialized flag so route changes and React strict-mode double-effects do not append a second rudderstack script, whose onload would iterate an already-drained (undefined) queue.
Contributor
|
Hello! 👋 This repository uses Auto for releasing packages using PR labels. ❌ This PR cannot be merged until the following issues are addressed:
🏷️ More info about which labels to use
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a production runtime error in the Docusaurus website tracking integration by preventing startTracking() from running more than once per module load. This avoids appending the RudderStack SDK script multiple times (e.g., via route changes and React strict-mode double effects), which previously could cause the SDK onload handler to iterate an already-drained rudderQueue and throw TypeError: rudderQueue is not iterable.
Changes:
- Add a module-level
trackingInitializedflag. - Guard
startTracking()so it becomes a one-time initializer whenshouldTrackis true.
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.
Guard
startTrackingwith a module-level initialized flag so route changes and React strict-mode double-effects do not append a second rudderstack script, whoseonloadwould iterate an already-drained (undefined)rudderQueueand throwTypeError: rudderQueue is not iterable.@Ukochka — does this look right to you? If so, would you be up for porting the same fix to the other Grafana sub-sites that share this tracking module?