-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Bug]: logPolitely logs on stdout #32487
Comments
The script being run here can only be |
That's correct.
I'm using Because In general* I think messages like "I'm going to install a browser", "I'm downloading it now", etc, fall under the latter category so belong on stderr and not stdout. * = "In general" is quite subjective, here are some references that discuss when to use stdout vs stderr:
|
@achingbrain How does your script run
|
That's true, unfortunately logPolitely is used during regular execution too, not just during I just saw this during a test run:
This uses
|
Could you please share a repro for this? I don't think playwright should download browsers during test execution. |
If a browser is downloaded during a test run, playwright will log on stdout. This can interfere with the calling code if it's trying to parse the output of the program as, for example, JSON. The fix is to temporarily replace `console.log` with `console.error` as that's what the [logPolitely](https://github.com/microsoft/playwright/blob/718bd9b35fd206245401a9ecb320289f427592d9/packages/playwright-core/src/server/registry/browserFetcher.ts#L120) function uses to give feedback to the user. The intention of the playwright maintainers is [not for this functionality to be used during a test run](microsoft/playwright#32487 (comment)) so it's unlikely to move to stderr otherwise.
If a browser is downloaded during a test run, playwright will log on stdout. This can interfere with the calling code if it's trying to parse the output of the program as, for example, JSON. The fix is to temporarily replace `console.log` with `console.error` as that's what the [logPolitely](https://github.com/microsoft/playwright/blob/718bd9b35fd206245401a9ecb320289f427592d9/packages/playwright-core/src/server/registry/browserFetcher.ts#L120) function uses to give feedback to the user. The intention of the playwright maintainers is [not for this functionality to be used during a test run](microsoft/playwright#32487 (comment)) so it's unlikely to move to stderr otherwise.
I think I've got to the bottom of this. We're using playwright-test as it's a really simple way to just run a script in many different browsers headlessly and does nice things like installing missing browsers if required. It uses the
That's a shame, it's really useful to not have to worry about this stuff. I'm going to close this since it's not using the tool in the way the authors intend it to be used, though it'd still be nice to have an option on the API to control the logging output. |
Version
1.47.0
Steps to reproduce
Run playwright on a platform without browsers installed.
The logPolitely function in browserFetch.ts logs using
console.log
which causes output on stdout.It should use
console.warn
orconsole.error
to log to stderr instead as it can interfere with the output of the script being run.Expected behavior
Playwright informational logging on stderr
Actual behavior
Playwright informational logging on stdout
Additional context
No response
Environment
The text was updated successfully, but these errors were encountered: