Skip to content

Commit 0b4a980

Browse files
authored
fix(driver): crash with VSCode debug terminal (microsoft#405)
1 parent d35d628 commit 0b4a980

File tree

8 files changed

+13
-8
lines changed

8 files changed

+13
-8
lines changed

playwright/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@
2020

2121
driver_executable = compute_driver_executable()
2222
my_env = os.environ.copy()
23+
# VSCode's JavaScript Debug Terminal provides it but driver/pkg does not support it
24+
my_env.pop("NODE_OPTIONS", None)
2325
my_env["PW_CLI_TARGET_LANG"] = "python"
2426
subprocess.run([str(driver_executable), *sys.argv[1:]], env=my_env)

playwright/_impl/_browser_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ async def waitForEvent(
215215
timeout = self._timeout_settings.timeout()
216216
wait_helper = WaitHelper(self._loop)
217217
wait_helper.reject_on_timeout(
218-
timeout, f'Timeout while waiting for event "${event}"'
218+
timeout, f'Timeout while waiting for event "{event}"'
219219
)
220220
if event != BrowserContext.Events.Close:
221221
wait_helper.reject_on_event(

playwright/_impl/_network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ async def waitForEvent(
301301
timeout = cast(Any, self._parent)._timeout_settings.timeout()
302302
wait_helper = WaitHelper(self._loop)
303303
wait_helper.reject_on_timeout(
304-
timeout, f'Timeout while waiting for event "${event}"'
304+
timeout, f'Timeout while waiting for event "{event}"'
305305
)
306306
if event != WebSocket.Events.Close:
307307
wait_helper.reject_on_event(

playwright/_impl/_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ async def waitForEvent(
537537
timeout = self._timeout_settings.timeout()
538538
wait_helper = WaitHelper(self._loop)
539539
wait_helper.reject_on_timeout(
540-
timeout, f'Timeout while waiting for event "${event}"'
540+
timeout, f'Timeout while waiting for event "{event}"'
541541
)
542542
if event != Page.Events.Crash:
543543
wait_helper.reject_on_event(self, Page.Events.Crash, Error("Page crashed"))

playwright/_impl/_transport.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ def stop(self) -> None:
4848

4949
async def run(self) -> None:
5050
self._loop = asyncio.get_running_loop()
51-
driver_executable = self._driver_executable
51+
52+
driver_env = os.environ.copy()
53+
# VSCode's JavaScript Debug Terminal provides it but driver/pkg does not support it
54+
driver_env.pop("NODE_OPTIONS", None)
5255

5356
proc = await asyncio.create_subprocess_exec(
54-
str(driver_executable),
57+
str(self._driver_executable),
5558
"run-driver",
59+
env=driver_env,
5660
stdin=asyncio.subprocess.PIPE,
5761
stdout=asyncio.subprocess.PIPE,
5862
stderr=_get_stderr_fileno(),

tests/async/test_har.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ async def test_should_include_content(browser, server, tmpdir):
5757
log = data["log"]
5858

5959
content1 = log["entries"][0]["response"]["content"]
60-
print(content1)
6160
assert content1["encoding"] == "base64"
6261
assert content1["mimeType"] == "text/html"
6362
s = base64.b64decode(content1["text"]).decode()

tests/async/test_headful.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def test_should_click_background_tab(browser_type, launch_arguments, serve
8989
browser = await browser_type.launch(**{**launch_arguments, "headless": False})
9090
page = await browser.new_page()
9191
await page.set_content(
92-
'<button>Hello</button><a target=_blank href="${server.EMPTY_PAGE}">empty.html</a>'
92+
f'<button>Hello</button><a target=_blank href="{server.EMPTY_PAGE}">empty.html</a>'
9393
)
9494
await page.click("a")
9595
await page.click("button")

tests/async/test_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ async def test_set_content_should_respect_timeout(page, server):
478478
server.set_route(img_path, lambda request: None)
479479
with pytest.raises(Error) as exc_info:
480480
await page.set_content(
481-
'<img src="${server.PREFIX + img_path}"></img>', timeout=1
481+
f'<img src="{server.PREFIX + img_path}"></img>', timeout=1
482482
)
483483
assert exc_info.type is TimeoutError
484484

0 commit comments

Comments
 (0)