bito-code-review[bot] commented on PR #41697:
URL: https://github.com/apache/superset/pull/41697#issuecomment-4887855245
<!-- Bito Reply -->
The flagged issue is correct. In environments where `document.fonts` or
`document.fonts.ready` is undefined, the optional chaining
`document.fonts?.ready?.then(...)` evaluates to `undefined`, causing the
subsequent `.catch` call to throw a `TypeError`.
To resolve this, you can guard the entire promise chain by checking for the
existence of `document.fonts?.ready` before chaining, or by using a safer
approach to handle the promise.
### Proposed Fix
```tsx
remeasure();
if (document.fonts?.ready) {
document.fonts.ready.then(remeasure).catch(() => {});
}
onLoad?.(editor);
```
This change ensures that the `.catch` method is only accessed if
`document.fonts.ready` exists, preventing the runtime error in environments
without the Font Loading API.
Would you like me to check the rest of the comments on this PR and implement
fixes for them as well?
**superset-frontend/packages/superset-ui-core/src/components/AsyncAceEditor/index.tsx**
```
remeasure();
if (document.fonts?.ready) {
document.fonts.ready.then(remeasure).catch(() => {});
}
onLoad?.(editor);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]