You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "kgabryje (via GitHub)" <gi...@apache.org> on 2025/12/11 16:38:20 UTC

[PR] chore: Close playwright browser gracefully [superset]

kgabryje opened a new pull request, #36537:
URL: https://github.com/apache/superset/pull/36537

   ### SUMMARY
   Explicitly close the Playwright browser after taking the screenshots. Currently the browser process gets killed after exiting the `with sync_playwright()` context, which sometimes causes exceptions like:
   ```
   Future exception was never retrieved
   future: <Future finished exception=TargetClosedError('Target page, context or browser has been closed')>
   ```
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Close playwright browser gracefully [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #36537:
URL: https://github.com/apache/superset/pull/36537#issuecomment-3642792857

   CodeAnt AI finished reviewing your PR.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Close playwright browser gracefully [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #36537:
URL: https://github.com/apache/superset/pull/36537#issuecomment-3642789164

   ## Nitpicks πŸ”
   
   <table>
   <tr><td>πŸ”’&nbsp;<strong>No security issues identified</strong></td></tr>
   <tr><td>⚑&nbsp;<strong>Recommended areas for review</strong><br><br>
   
   - [ ] <a href='https://github.com/apache/superset/pull/36537/files#diff-ee5af2b5ab4555c2f1d3d31d44fecd1c14bf03e13aa88cb0d15862d7dcea57bbR396-R397'><strong>Cleanup Exception</strong></a><br>The newly added unconditional call to `browser.close()` in the finally block can itself raise exceptions (if `browser` is None, already closed, or closing fails). That may mask the original exception or cause new errors during cleanup. Ensure the close is guarded and exceptions during close are handled.<br>
   
   - [ ] <a href='https://github.com/apache/superset/pull/36537/files#diff-ee5af2b5ab4555c2f1d3d31d44fecd1c14bf03e13aa88cb0d15862d7dcea57bbR392-R397'><strong>Incomplete Resource Cleanup</strong></a><br>Only calling `browser.close()` may not be sufficient β€” `page` and `context` created earlier are not explicitly closed. Relying solely on `browser.close()` might still leave background tasks or cause "TargetClosedError" if ordering of closures is not handled. Consider explicitly closing `page` and `context` (or using context managers) before closing the browser.<br>
   
   </td></tr>
   </table>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Close playwright browser gracefully [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on PR #36537:
URL: https://github.com/apache/superset/pull/36537#issuecomment-3642782222

   CodeAnt AI is reviewing your PR.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Close playwright browser gracefully [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #36537:
URL: https://github.com/apache/superset/pull/36537#discussion_r2611304926


##########
superset/utils/webdriver.py:
##########
@@ -393,6 +393,8 @@ def get_screenshot(  # pylint: disable=too-many-locals, too-many-statements  # n
                 logger.exception(
                     "Encountered an unexpected error when requesting url %s", url
                 )
+            finally:
+                browser.close()

Review Comment:
   **Suggestion:** `browser` may not be defined if an earlier step raises before the browser is assigned; calling `browser.close()` unguarded will raise a NameError/UnboundLocalError β€” check for the presence of `browser` (and that it's not None) before calling `.close()`. [null pointer]
   
   **Severity Level:** Minor ⚠️
   ```suggestion
                   if "browser" in locals() and browser is not None:
   ```
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   If an exception occurs before browser is assigned, the unguarded browser.close() will raise an UnboundLocalError/NameError. Checking for browser's presence (and non-None) before calling close is a minimal, correct fix for that specific failure mode. It doesn't guard against close() itself raising, but it resolves the immediate NameError risk.
   </details>
   <details>
   <summary><b>Prompt for AI Agent πŸ€– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/utils/webdriver.py
   **Line:** 397:397
   **Comment:**
   	*Null Pointer: `browser` may not be defined if an earlier step raises before the browser is assigned; calling `browser.close()` unguarded will raise a NameError/UnboundLocalError β€” check for the presence of `browser` (and that it's not None) before calling `.close()`.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
   ```
   </details>



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Close playwright browser gracefully [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #36537:
URL: https://github.com/apache/superset/pull/36537#issuecomment-3642815902

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/36537?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `0%` with `1 line` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 47.88%. Comparing base ([`a745fd4`](https://app.codecov.io/gh/apache/superset/commit/a745fd49fa49b2a3dc40ddc5310bcfc11940a4e0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`3dc1d41`](https://app.codecov.io/gh/apache/superset/commit/3dc1d41895dc1e6f4b30b8320a3691433e7f4dfc?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 108 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/36537?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/utils/webdriver.py](https://app.codecov.io/gh/apache/superset/pull/36537?src=pr&el=tree&filepath=superset%2Futils%2Fwebdriver.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvdXRpbHMvd2ViZHJpdmVyLnB5) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/36537?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #36537       +/-   ##
   ===========================================
   + Coverage        0   47.88%   +47.88%     
   ===========================================
     Files           0      637      +637     
     Lines           0    47102    +47102     
     Branches        0     5131     +5131     
   ===========================================
   + Hits            0    22553    +22553     
   - Misses          0    23894    +23894     
   - Partials        0      655      +655     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/36537/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ” | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/36537/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `43.50% <0.00%> (?)` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/36537/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `47.14% <0.00%> (?)` | |
   | [python](https://app.codecov.io/gh/apache/superset/pull/36537/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `47.87% <0.00%> (?)` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/36537/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ΓΈ> (?)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/36537?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] chore: Close playwright browser gracefully [superset]

Posted by "kgabryje (via GitHub)" <gi...@apache.org>.
kgabryje merged PR #36537:
URL: https://github.com/apache/superset/pull/36537


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org