Skip to content

Commit

Permalink
fix: don't throw if loading youtube script fails
Browse files Browse the repository at this point in the history
Not all campaigns use and require youtube to operate. If youtube is blocked in your country, this will fail to load, killing the startup.

To avoid that, we just console error the failure instead.

This should probably resolve all those failed to load youtube duplicates.

Refs: cyruzzo#2637 (and others)
  • Loading branch information
MonstraG committed Feb 2, 2025
1 parent f0f49a1 commit 7ceeeef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,13 @@ function load_external_script(scriptUrl) {
return new Promise(function (resolve, reject) {
let script = document.createElement('script');
script.src = scriptUrl;
script.addEventListener('error', function () {
reject(console.warn(`Failed to load external script ${scriptUrl}`));
script.addEventListener('error', err => {
reject(err);
});
script.addEventListener('load', resolve);
document.head.appendChild(script);
}).catch((err) => {
console.error(`Failed to load external script`, scriptUrl, err);
})
}

Expand Down

0 comments on commit 7ceeeef

Please sign in to comment.