Skip to content

Commit 1cce06a

Browse files
x0daymxschmitt
andauthored
fix: Task exception was never retrieved when continue_ race with page closed event (#1167)
closes #1165 Co-authored-by: Max Schmitt <[email protected]>
1 parent 6b64fb8 commit 1cce06a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

playwright/_impl/_network.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,10 +285,13 @@ async def _race_with_page_close(self, future: Coroutine) -> None:
285285
# When page closes or crashes, we catch any potential rejects from this Route.
286286
# Note that page could be missing when routing popup's initial request that
287287
# does not have a Page initialized just yet.
288+
fut = asyncio.create_task(future)
288289
await asyncio.wait(
289-
[asyncio.create_task(future), page._closed_or_crashed_future],
290+
[fut, page._closed_or_crashed_future],
290291
return_when=asyncio.FIRST_COMPLETED,
291292
)
293+
if page._closed_or_crashed_future.done():
294+
await asyncio.gather(fut, return_exceptions=True)
292295
else:
293296
await future
294297

0 commit comments

Comments
 (0)