Skip to content

Commit db60142

Browse files
committed
fix: timeout option support with fetch api
1 parent 6e9ff7a commit db60142

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

playwright/_impl/_fetch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ async def _inner_fetch(
412412
self._timeout_settings.timeout,
413413
{
414414
"url": url,
415+
"timeout": timeout,
415416
"params": object_to_array(params) if isinstance(params, dict) else None,
416417
"encodedParams": params if isinstance(params, str) else None,
417418
"method": method,

tests/async/test_fetch_global.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ async def test_should_support_global_timeout_option(
8989
await request.get(server.EMPTY_PAGE)
9090

9191

92+
async def test_should_support_timeout_option_in_get_method(
93+
playwright: Playwright, server: Server
94+
) -> None:
95+
request = await playwright.request.new_context()
96+
server.set_route("/empty.html", lambda req: None)
97+
with pytest.raises(
98+
Error, match="APIRequestContext.get: Request timed out after 123ms"
99+
):
100+
await request.get(server.EMPTY_PAGE, timeout=123)
101+
102+
92103
async def test_should_propagate_extra_http_headers_with_redirects(
93104
playwright: Playwright, server: Server
94105
) -> None:

tests/sync/test_fetch_global.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ def test_should_support_global_timeout_option(
7171
request.get(server.EMPTY_PAGE)
7272

7373

74+
def test_should_support_timeout_option_in_get_method(
75+
playwright: Playwright, server: Server
76+
) -> None:
77+
request = playwright.request.new_context()
78+
server.set_route("/empty.html", lambda req: None)
79+
with pytest.raises(
80+
Error, match="APIRequestContext.get: Request timed out after 123ms"
81+
):
82+
request.get(server.EMPTY_PAGE, timeout=123)
83+
84+
7485
def test_should_propagate_extra_http_headers_with_redirects(
7586
playwright: Playwright, server: Server
7687
) -> None:

0 commit comments

Comments
 (0)