Skip to content

Commit 60d6fd9

Browse files
committed
fix issue where published docs containing mpld3 plots crash when viewed on share server, due to security constraints
1 parent 3afdb88 commit 60d6fd9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/packages/frontend/jupyter/output-messages/mime-types/iframe-html.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,19 @@ const IframeHtml = ({ value }) => {
2121
// TODO: Might wnat to switch to https://www.npmjs.com/package/iframe-resizer-react
2222
// instead of the hack of timeouts below...
2323
useEffect(() => {
24-
if (iframeRef.current == null) return;
24+
if (iframeRef.current == null) {
25+
return;
26+
}
2527
const f = () => {
2628
if (iframeRef.current != null && isMountedRef.current) {
27-
iframeRef.current.height = `${
28-
iframeRef.current.contentWindow.document.documentElement
29-
?.offsetHeight ?? 600
30-
}px`;
29+
try {
30+
iframeRef.current.height = `${
31+
iframeRef.current.contentWindow.document.documentElement
32+
?.offsetHeight ?? 600
33+
}px`;
34+
} catch (_err) {
35+
// this fails on the share server for security reasons, which is good.
36+
}
3137
}
3238
};
3339
f();

0 commit comments

Comments
 (0)