Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix WebDriver resource leak in HTML-to-PDF conversion (#14310)

Ricardo-M-L48b4aa3e93b2
diff --git a/api/utils/web_utils.py b/api/utils/web_utils.py
index 23d2421862..e7c1b48f51 100644
--- a/api/utils/web_utils.py
+++ b/api/utils/web_utils.py
@@ -173,6 +173,9 @@ def __get_pdf_from_html(path: str, timeout: int, install_driver: bool, print_opt
try:
WebDriverWait(driver, timeout).until(staleness_of(driver.find_element(by=By.TAG_NAME, value="html")))
except TimeoutException:
+ pass
+
+ try:
calculated_print_options = {
"landscape": False,
"displayHeaderFooter": False,
@@ -181,8 +184,9 @@ def __get_pdf_from_html(path: str, timeout: int, install_driver: bool, print_opt
}
calculated_print_options.update(print_options)
result = __send_devtools(driver, "Page.printToPDF", calculated_print_options)
- driver.quit()
return base64.b64decode(result["data"])
+ finally:
+ driver.quit()
def is_valid_url(url: str) -> bool: