Skip to content

Commit

Permalink
tolerate remote script errors better
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGermaneri committed Sep 24, 2023
1 parent 95255e6 commit 891a115
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/workspace/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ export default (router: Router) => {
router.beforeEach(async (to, from, next) => {
console.log('Route', to, from);
const scripts = (usePreferencesStore() as any).preferences.componentScripts.replace('\n', ',').split(',');
const promises = scripts.map((src) => {
const promises = scripts.map((src: string) => {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.async = false;
script.src = src;
script.onload = resolve;
script.onerror = reject;
script.onerror = (err) => {
console.error(`Error loading script (src: ${src}) from preferences: ${err}`);
};
document.head.appendChild(script);
});
});
Expand Down

0 comments on commit 891a115

Please sign in to comment.