A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: more defensive stylesheet copy (#1606)
Myles Scolnick22e52b1895ae
diff --git a/frontend/src/plugins/core/registerReactComponent.tsx b/frontend/src/plugins/core/registerReactComponent.tsxindex b8efb57a1a..8b57a69a2c 100644--- a/frontend/src/plugins/core/registerReactComponent.tsx+++ b/frontend/src/plugins/core/registerReactComponent.tsx@@ -378,17 +378,23 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {// We need to create a new stylesheet because we can't use the same// stylesheet otherwise the browser will throw an error.const newSheet = new CSSStyleSheet();- newSheet.replaceSync(- Array.from(sheet.cssRules)- .map((rule) => {- if (rule.cssText.includes("@import")) {- // @import rules are not supported in adoptedStyleSheets- return "";- }- return rule.cssText;- })- .join("\n"),- );+ try {+ newSheet.replaceSync(+ Array.from(sheet.cssRules)+ .map((rule) => {+ if (rule.cssText.includes("@import")) {+ // @import rules are not supported in adoptedStyleSheets+ return "";+ }+ return rule.cssText;+ })+ .join("\n"),+ );+ } catch {+ // It is possible that the stylesheet is not accessible due to CORS+ // We can ignore this error+ }+styleSheetCache.set(sheetUniqueKey, newSheet);}}@@ -417,9 +423,16 @@ export function registerReactComponent<T>(plugin: IPlugin<T, unknown>): void {}const style = document.createElement("style");- style.textContent = Array.from(sheet.cssRules)- .map((rule) => rule.cssText)- .join("\n");+ try {+ style.textContent = Array.from(sheet.cssRules)+ .map((rule) => rule.cssText)+ .join("\n");+ } catch {+ // It is possible that the stylesheet is not accessible due to CORS+ // We can ignore this error+ return [];+ }+return [style];});@@ -444,6 +457,11 @@ function shouldCopyStyleSheet(sheet: CSSStyleSheet): boolean {return false;}+ // Must end with .css+ if (!sheet.href.endsWith(".css")) {+ return false;+ }+if (sheet.href.includes("127.0.0.1") &&(process.env.NODE_ENV === "test" || process.env.NODE_ENV === "development")