Skip to content

Commit

Permalink
fix: Task exception was never retrieved when continue_ race with page…
Browse files Browse the repository at this point in the history
… closed event (#1167)

closes #1165

Co-authored-by: Max Schmitt <max@schmitt.mx>
  • Loading branch information
x0day and mxschmitt authored Feb 23, 2022
1 parent 6b64fb8 commit 1cce06a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion playwright/_impl/_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,13 @@ async def _race_with_page_close(self, future: Coroutine) -> None:
# When page closes or crashes, we catch any potential rejects from this Route.
# Note that page could be missing when routing popup's initial request that
# does not have a Page initialized just yet.
fut = asyncio.create_task(future)
await asyncio.wait(
[asyncio.create_task(future), page._closed_or_crashed_future],
[fut, page._closed_or_crashed_future],
return_when=asyncio.FIRST_COMPLETED,
)
if page._closed_or_crashed_future.done():
await asyncio.gather(fut, return_exceptions=True)
else:
await future

Expand Down

0 comments on commit 1cce06a

Please sign in to comment.