File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -204,12 +204,19 @@ const CloudinaryImageWidget: React.FC<CloudinaryWidgetProps> = ({
204204 if ( src && ! src . endsWith ( "undefined" ) ) {
205205 setLocalSrc ( src ) ;
206206 }
207- // Poll briefly for the blob to be populated by the CMS proxy
207+ // Poll briefly for the blob to be populated by the CMS proxy.
208+ // Cap attempts so the interval doesn't leak if the value never
209+ // changes (e.g., src was already resolved or stays unresolved).
210+ let attempts = 0 ;
211+ const MAX_POLL_ATTEMPTS = 20 ;
208212 const interval = setInterval ( ( ) => {
213+ attempts ++ ;
209214 const resolved = getAsset ( value , field ) . toString ( ) ;
210215 if ( resolved && resolved !== src ) {
211216 setLocalSrc ( resolved ) ;
212217 clearInterval ( interval ) ;
218+ } else if ( attempts >= MAX_POLL_ATTEMPTS ) {
219+ clearInterval ( interval ) ;
213220 }
214221 } , 500 ) ;
215222 return ( ) => clearInterval ( interval ) ;
Original file line number Diff line number Diff line change @@ -112,7 +112,9 @@ interface QueryResult {
112112const DiseaseCatalog = ( { data } : QueryResult ) => {
113113 const { markdownRemark : post } = data ;
114114 const imageFile = post . frontmatter . header ?. background ;
115- const backgroundImageUrl = getImageSrcFromFileNode ( imageFile ! ) ;
115+ const backgroundImageUrl = imageFile
116+ ? getImageSrcFromFileNode ( imageFile )
117+ : undefined ;
116118 return (
117119 < Layout
118120 header = {
You can’t perform that action at this time.
0 commit comments