bito-code-review[bot] commented on PR #40694:
URL: https://github.com/apache/superset/pull/40694#issuecomment-4608136736
<!-- Bito Reply -->
The flagged issue is correct. The current implementation unconditionally
executes `page.wait_for_timeout(animation_wait * 1000)` even if the preceding
`wait_for_function` call (which checks for loading spinners) has timed out.
This unnecessarily extends the duration of failed tasks.
To resolve this, you should wrap the animation wait in a check that ensures
the spinner wait was successful. Since the spinner wait is inside a
`try...except` block, you can set a flag or check the result of the spinner
wait before applying the animation delay.
Here is a concise fix for `superset/utils/screenshot_utils.py`:
```python
# Wait for chart animations (e.g. ECharts) to finish after
spinner clears.
# Only apply if the spinner check succeeded.
if animation_wait > 0:
try:
page.wait_for_function(
"() => !document.querySelector('.loading')",
timeout=load_wait * 1000,
)
page.wait_for_timeout(animation_wait * 1000)
except Exception:
logger.warning("Spinner check timed out, skipping
animation wait.")
```
There are no other comments in this PR. Would you like me to review any
other parts of the code?
**superset/utils/screenshot_utils.py**
```
# Wait for chart animations (e.g. ECharts) to finish after spinner clears.
# Only apply if the spinner check succeeded.
if animation_wait > 0:
try:
page.wait_for_function(
"() => !document.querySelector('.loading')",
timeout=load_wait * 1000,
)
page.wait_for_timeout(animation_wait * 1000)
except Exception:
logger.warning("Spinner check timed out, skipping
animation wait.")
```
--
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]