Skip to content

Commit c19d226

Browse files
committed
fix(tracing): apiName calculation for route handlers
1 parent 47913e2 commit c19d226

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

playwright/_impl/_network.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import asyncio
1616
import base64
17+
import inspect
1718
import json
1819
import mimetypes
1920
from collections import defaultdict
@@ -369,6 +370,14 @@ async def _race_with_page_close(self, future: Coroutine) -> None:
369370
# Note that page could be missing when routing popup's initial request that
370371
# does not have a Page initialized just yet.
371372
fut = asyncio.create_task(future)
373+
# Rewrite the user's stack to the new task which runs in the background.
374+
setattr(
375+
fut,
376+
"__pw_stack__",
377+
getattr(
378+
asyncio.current_task(self._loop), "__pw_stack__", inspect.stack()
379+
),
380+
)
372381
await asyncio.wait(
373382
[fut, page._closed_or_crashed_future],
374383
return_when=asyncio.FIRST_COMPLETED,

tests/async/test_tracing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ async def test_should_collect_trace_with_resources_but_no_js(
107107
"Page.wait_for_timeout",
108108
"Page.route",
109109
"Page.goto",
110-
# FIXME: https://github.com/microsoft/playwright-python/issues/1397
111-
"Channel.send",
110+
"Route.continue_",
112111
"Page.close",
113112
"Tracing.stop",
114113
]

tests/sync/test_tracing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def test_should_collect_trace_with_resources_but_no_js(
107107
"Page.wait_for_timeout",
108108
"Page.route",
109109
"Page.goto",
110-
# FIXME: https://github.com/microsoft/playwright-python/issues/1397
111-
"Channel.send",
110+
"Route.continue_",
112111
"Page.close",
113112
"Tracing.stop",
114113
]

0 commit comments

Comments
 (0)