mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
Added try/catch to iFrame buffering in Settings (#19790)
refs https://ghost.slack.com/archives/CTH5NDJMS/p1709230854358779 - Customer reported that some code they injected via the Code Injection crashed the Preview in Ghost Settings. - This wraps the function where the crash took place (according to Sentry) in a try/catch to attempt to handle it gracefully. - Added an additional Sentry log to better understand the situation should it happen again.
This commit is contained in:
parent
9df5148427
commit
2816c2c128
@ -1,3 +1,4 @@
|
|||||||
|
import * as Sentry from '@sentry/react';
|
||||||
import React, {useEffect, useRef, useState} from 'react';
|
import React, {useEffect, useRef, useState} from 'react';
|
||||||
|
|
||||||
type IframeBufferingProps = {
|
type IframeBufferingProps = {
|
||||||
@ -62,7 +63,15 @@ const IframeBuffering: React.FC<IframeBufferingProps> = ({generateContent, class
|
|||||||
const iframe = iframes[visibleIframeIndex].current;
|
const iframe = iframes[visibleIframeIndex].current;
|
||||||
|
|
||||||
if (iframe) {
|
if (iframe) {
|
||||||
iframe.contentWindow?.scrollTo(0, scrollPosition);
|
// refs https://ghost-foundation.sentry.io/issues/5024564293/
|
||||||
|
// Customer reported that code they injected caused Settings to crash.
|
||||||
|
// According to Sentry this the line that caused the crash.
|
||||||
|
// We are adding a try catch block to attempt to catch the error for further investigation and prevent the crash.
|
||||||
|
try {
|
||||||
|
iframe.contentWindow?.scrollTo(0, scrollPosition);
|
||||||
|
} catch (e) {
|
||||||
|
Sentry.captureException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [scrollPosition, visibleIframeIndex, iframes]);
|
}, [scrollPosition, visibleIframeIndex, iframes]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user