diff --git a/utils/markdown_to_image.py b/utils/markdown_to_image.py index 9c67301..39c51be 100644 --- a/utils/markdown_to_image.py +++ b/utils/markdown_to_image.py @@ -770,7 +770,11 @@ async def _run_in_md2img_runtime(coro, timeout_seconds: Optional[int] = None): awaitable_future = asyncio.wrap_future(future) if timeout_seconds is not None: return await asyncio.wait_for(awaitable_future, timeout=max(1, int(timeout_seconds))) - return awaitable_future + # 关键修复: + # 之前这里直接 return Future 对象,调用方 await 后只拿到 Future 本身, + # 导致业务层误以为截图已完成,实际截图仍在后台执行,出现“先判失败后截图”的时序错乱。 + # 这里必须等待 Future 完成并返回真实结果,保证调用链严格串行。 + return await awaitable_future def _get_browser_manager() -> _PersistentBrowser: