Skip to content
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] webServer uses proxy settings in .yarnrc for v1.31.2+ when running via yarn #23219

Closed
1 task done
danvim opened this issue May 23, 2023 · 2 comments
Closed
1 task done

Comments

@danvim
Copy link

danvim commented May 23, 2023

System info

  • Playwright Version: [v1.31.2 to v1.34.0] All versions are tested with corresponding image and npm package version.
  • Operating System: [Docker playwright:v1.34.0, etc]
  • Other info:

Source code

  • I provided exact source code that allows reproducing the issue locally.

Config file

// playwright.config.ts
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  webServer: {
    command: 'node ./start-server.js',
    url: 'http://localhost:10039', // I also tested with 127.0.0.1 with the same result.
    timeout: 120 * 1000,
    reuseExistingServer: false
  },
  use: {
    baseUrl: 'http://localhost:10039'
  }
});

/etc/hosts

127.0.0.1    localhost
::1    localhost ip6-localhost ip6-loopback
...

$http_proxy, $https_proxy, $no_proxy, and their upper case versions are all unset.

.yarnrc includes proxy and https-proxy settings.

Steps

  • Run DEBUG=pw:webserver npx playwright test

Expected

Ignore other proxy envs (like npm_config_proxy) other than http_proxy, https_proxy to match browser behavior.

Playwright v.1.31.1 and below.

$ npx playwright test
[timestamp] pw:server HTTP GET: http://localhost:10039/
[timestamp] pw:server Error while checking if http://localhost:10039/ is available: connect ECONNREFUSED ::1:10039
[timestamp] pw:server Starting WebServer process node ./start-server.js
[timestamp] pw:server Process started
[timestamp] pw:server Waiting for availability...
[timestamp] pw:server HTTP GET http://localhost:10039/
[timestamp] pw:server Error while checking if http://localhost:10039/ is available: connect ECONNREFUSED ::1:10039
[timestamp] pw:server Waiting 100ms
...
[timestamp] pw:server HTTP GET: http://localhost:10039/
[around 20s] pw:server HTTP Status: 200
[timestamp] pw:server WebServer available

Actual

Network pinging uses other proxy envs (like npm_config_proxy) other than http_proxy, https_proxy.

Playwright v1.31.2 and above. I am only able to reproduce it in our company's GitLab CI K8S environment. I tried reproducing it locally (Podman container) and v1.31.2 and above works fine.

$ npx playwright test
[timestamp] pw:server HTTP GET: http://localhost:10039/
[timestamp] pw:server HTTP Status: 407
[timestamp] pw:server Starting WebServer process node ./start-server.js
[timestamp] pw:server Process started
[timestamp] pw:server Waiting for availability...
[timestamp] pw:server HTTP GET http://localhost:10039/
[timestamp] pw:server HTTP Status: 407
[timestamp] pw:server Waiting 100ms
...
[timestamp] pw:server HTTP GET: http://localhost:10039/
[timestamp] pw:server HTTP Status: 407
Error: Timed out waiting 120000ms from config.webServer.
error Command failed with exit code 1.

Seeing the changes of v1.31.2 related to webServer (#21227), I made my own debug script. But my script runs fine in v1.31.2 and above:

test-server.js

const utils = require('playwright-core/lib/utils');
const {httpRequest} = utils;

httpRequest(
  {
    url: 'http://localhost:10039/',
    headers: {Accept: '*/*'},
    rejectUnauthorized: true,
  },
  res => {
    res.resume();
    const statusCode = res.statusCode;
    console.log(statusCode);
    
    let body = '';
    res.on('data', chunk => { body += chunk; };
    res.on('end', () => { console.log(body); });
  },
  console.error,
)

/*
node ./start-server.js &
sleep 30
node ./test-server.js
*/

/*
200
<!doctype html>...
*/

Removing webServer config and running this also works fine:

node ./start-server.js &
sleep 30
npx playwright test
@danvim
Copy link
Author

danvim commented May 24, 2023

I found the issue, v1.31.2+ uses .yarnrc's configuration for proxy and https-proxy. We specified them for package download, but did not expect them to take effect for playwright's CLI when running through yarn yarn test ("test": "npx playwright test") instead of npx playwright test. Is this behavior expected or out of bound for a playwright issue?

I have updated issue's title.

@danvim danvim changed the title [BUG] webServer fails to ping running server with 407 proxy authentication required error [BUG] webServer uses proxy settings in .yarnrc for v1.13.2+ when running via yarn May 24, 2023
@aslushnikov aslushnikov changed the title [BUG] webServer uses proxy settings in .yarnrc for v1.13.2+ when running via yarn [BUG] webServer uses proxy settings in .yarnrc for v1.31.2+ when running via yarn May 24, 2023
@aslushnikov
Copy link
Collaborator

@danvim Yes, this is an expected behavior; the yarnrc defines proxy settings for all the commands that yarn runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants