fix: youtube race condition when GTM loads#33649
Conversation
|
Thanks for the pull request, @viadanna! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
|
Hi @viadanna! Just flagging that there are some failing checks. Would you mind taking a look? |
|
Sure thing @mphilbrick211 |
|
@mphilbrick211 There was a problem with the testing infrastructure, can you restart the unit-tests workflow? |
|
Hi @viadanna! I'm looking into this for you. |
|
Hi @viadanna! All looks OK now, so I'm marking this as ready for review. |
|
Hi @viadanna @mphilbrick211 may I review/merge this PR as CC? |
|
Sure thing @pomegranited |
|
@viadanna Which Jira ticket is this issue for? |
|
@pomegranited BB-7904 (private) |
pomegranited
left a comment
There was a problem hiding this comment.
👍
I wasn't able to reproduce the actual race condition (on master), but race conditions can be hard to reproduce. Instead, I verified that this change does not break videos or GA4 analytics.
- I tested this using the PR test instructions.
- I read through the code.
-
I checked for accessibility issuesN/A -
Includes documentationN/A -
User-facing strings are extracted for translationN/A
|
👍
|
|
@viadanna 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production. |
|
2U Release Notice: This PR has been deployed to the edX production environment. |
1 similar comment
|
2U Release Notice: This PR has been deployed to the edX production environment. |

Description
The changes fix an issue with YouTube videos when Google Analytics is used. It prevents the video XBlock from properly loading YouTube videos.
It's caused by a race condition, in which both Open edX and GTM implement onYouTubeIframeAPIReady and run already existing implementations of this callback.
The issue arises when GTM overwrites it, as the callback implemented by Open edX expects a
resolve()attribute that isn't implemented by GTM. This change ensures the original global is used by Open edX so it's never overwritten.Testing instructions
Testing
onYouTubeIframeAPIReadyis overwritten by GTM.Deadline
"None"
Other information