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

safaridriver.start() conflicts with webdriverio.remote() #4706

Closed
6 tasks done
mbland opened this issue Dec 8, 2023 · 2 comments · Fixed by #4863
Closed
6 tasks done

safaridriver.start() conflicts with webdriverio.remote() #4706

mbland opened this issue Dec 8, 2023 · 2 comments · Fixed by #4863
Labels
feat: browser Issues and PRs related to the browser runner pr welcome

Comments

@mbland
Copy link
Contributor

mbland commented Dec 8, 2023

Describe the bug

safaridriver.start() maintains a static reference to a safaridriver instance, and will fail with the following message if start() is called again before stop():

Error: There is already a Safaridriver instance running on port undefined!

packages/browser/node/providers/webdriver.ts calls safaridriver.start() directly, and then immediately imports and calls webdriverio.remote(). This call also eventually calls safaridriver.start(), producing the above error.

I already have a tested fix ready to turn into a PR here: mbland@64b9bbd

Reproduction

On macOS:

git clone https://github.com/vitest-dev/vitest.git
cd vitest
git reset --hard v1.0.2
pnpm i
pnpm build
cd test/browser
npx vitest --run --browser.name=safari

You'll see the stack trace pointing to the webdriverio.remote() call leading to the second safaridriver.start() call:

Error: There is already a Safaridriver instance running on port undefined!
 ❯ start ../../node_modules/.pnpm/safaridriver@0.1.0/node_modules/safaridriver/dist/index.js:26:15
 ❯ startWebDriver ../../node_modules/.pnpm/@wdio+utils@8.22.0/node_modules/@wdio/utils/build/node/startWebDriver.js:66:25
 ❯ process.processTicksAndRejections node:internal/process/task_queues:95:5
 ❯ WebDriver.newSession ../../node_modules/.pnpm/webdriver@8.22.1/node_modules/webdriver/build/index.js:18:31
 ❯ remote ../../node_modules/.pnpm/webdriverio@8.22.1_typescript@5.2.2/node_modules/webdriverio/build/index.js:45:22
 ❯ WebdriverBrowserProvider.openBrowser ../../packages/browser/dist/providers.js:81:26
     79|     }                                                                  
     80|     const { remote } = await import('webdriverio');
     81|     this.cachedBrowser = await remote({
       |                          ^
     82|       ...this.options,
     83|       logLevel: "error",                                               
 ❯ WebdriverBrowserProvider.openPage ../../packages/browser/dist/providers.js:109:29
 [ ...snip... ]

System Info

System:
    OS: macOS 14.1.2
    CPU: (10) arm64 Apple M1 Max
    Memory: 8.75 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.nodenv/versions/20.10.0/bin/node
    npm: 10.2.3 - ~/.nodenv/versions/20.10.0/bin/npm
    pnpm: 8.11.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 120.0.6099.71
    Safari: 17.1.2
  npmPackages:
    @vitest/browser: workspace:* => 1.0.2
    vitest: workspace:* => 1.0.2

Used Package Manager

pnpm

Validations

@sheremet-va
Copy link
Member

I already have a tested fix ready to turn into a PR here: mbland@64b9bbd

I don't see an open PR in this repo 🤔

@sheremet-va sheremet-va added bug pr welcome feat: browser Issues and PRs related to the browser runner and removed pending triage labels Jan 3, 2024
@mbland
Copy link
Contributor Author

mbland commented Jan 3, 2024

@sheremet-va Just rebased to the most recent main and filed #4863.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: browser Issues and PRs related to the browser runner pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants