Skip to content

fix(driver): crash with VSCode debug terminal #405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions playwright/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@

driver_executable = compute_driver_executable()
my_env = os.environ.copy()
# VSCode's JavaScript Debug Terminal provides it but driver/pkg does not support it
my_env.pop("NODE_OPTIONS", None)
my_env["PW_CLI_TARGET_LANG"] = "python"
subprocess.run([str(driver_executable), *sys.argv[1:]], env=my_env)
2 changes: 1 addition & 1 deletion playwright/_impl/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ async def waitForEvent(
timeout = self._timeout_settings.timeout()
wait_helper = WaitHelper(self._loop)
wait_helper.reject_on_timeout(
timeout, f'Timeout while waiting for event "${event}"'
timeout, f'Timeout while waiting for event "{event}"'
)
if event != BrowserContext.Events.Close:
wait_helper.reject_on_event(
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ async def waitForEvent(
timeout = cast(Any, self._parent)._timeout_settings.timeout()
wait_helper = WaitHelper(self._loop)
wait_helper.reject_on_timeout(
timeout, f'Timeout while waiting for event "${event}"'
timeout, f'Timeout while waiting for event "{event}"'
)
if event != WebSocket.Events.Close:
wait_helper.reject_on_event(
Expand Down
2 changes: 1 addition & 1 deletion playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ async def waitForEvent(
timeout = self._timeout_settings.timeout()
wait_helper = WaitHelper(self._loop)
wait_helper.reject_on_timeout(
timeout, f'Timeout while waiting for event "${event}"'
timeout, f'Timeout while waiting for event "{event}"'
)
if event != Page.Events.Crash:
wait_helper.reject_on_event(self, Page.Events.Crash, Error("Page crashed"))
Expand Down
8 changes: 6 additions & 2 deletions playwright/_impl/_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,15 @@ def stop(self) -> None:

async def run(self) -> None:
self._loop = asyncio.get_running_loop()
driver_executable = self._driver_executable

driver_env = os.environ.copy()
# VSCode's JavaScript Debug Terminal provides it but driver/pkg does not support it
driver_env.pop("NODE_OPTIONS", None)

proc = await asyncio.create_subprocess_exec(
str(driver_executable),
str(self._driver_executable),
"run-driver",
env=driver_env,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=_get_stderr_fileno(),
Expand Down
1 change: 0 additions & 1 deletion tests/async/test_har.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ async def test_should_include_content(browser, server, tmpdir):
log = data["log"]

content1 = log["entries"][0]["response"]["content"]
print(content1)
assert content1["encoding"] == "base64"
assert content1["mimeType"] == "text/html"
s = base64.b64decode(content1["text"]).decode()
Expand Down
2 changes: 1 addition & 1 deletion tests/async/test_headful.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def test_should_click_background_tab(browser_type, launch_arguments, serve
browser = await browser_type.launch(**{**launch_arguments, "headless": False})
page = await browser.new_page()
await page.set_content(
'<button>Hello</button><a target=_blank href="${server.EMPTY_PAGE}">empty.html</a>'
f'<button>Hello</button><a target=_blank href="{server.EMPTY_PAGE}">empty.html</a>'
)
await page.click("a")
await page.click("button")
Expand Down
2 changes: 1 addition & 1 deletion tests/async/test_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ async def test_set_content_should_respect_timeout(page, server):
server.set_route(img_path, lambda request: None)
with pytest.raises(Error) as exc_info:
await page.set_content(
'<img src="${server.PREFIX + img_path}"></img>', timeout=1
f'<img src="{server.PREFIX + img_path}"></img>', timeout=1
)
assert exc_info.type is TimeoutError

Expand Down