Skip to content

fix(webdriverio): use AbortSignal.timeout() instead of an AbortController#13783

Closed
christian-bromann wants to merge 1 commit intomainfrom
cb/fix-timeout
Closed

fix(webdriverio): use AbortSignal.timeout() instead of an AbortController#13783
christian-bromann wants to merge 1 commit intomainfrom
cb/fix-timeout

Conversation

@christian-bromann
Copy link
Member

@christian-bromann christian-bromann commented Oct 21, 2024

Proposed changes

use AbortSignal.timeout(timeout) instead of initiating an AbortController.

fixes #13778

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

//: # (The current main branch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against the v8 branch.)

  • This change is solely for v9 and doesn't need to be back-ported
  • Back-ported PR at #XXXXX

Further comments

@mykola-mokhnach mind checking if this resolves the issue?

Reviewers: @webdriverio/project-committers

@christian-bromann christian-bromann added the PR: Bug Fix 🐛 PRs that contain bug fixes label Oct 21, 2024
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 21, 2024

Open in Stackblitz

eslint-plugin-wdio

pnpm add https://pkg.pr.new/webdriverio/webdriverio/eslint-plugin-wdio@13783

@wdio/allure-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/allure-reporter@13783

@wdio/appium-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/appium-service@13783

@wdio/browserstack-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/browserstack-service@13783

@wdio/browser-runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/browser-runner@13783

@wdio/cli

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/cli@13783

@wdio/concise-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/concise-reporter@13783

@wdio/config

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/config@13783

@wdio/cucumber-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/cucumber-framework@13783

@wdio/firefox-profile-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/firefox-profile-service@13783

@wdio/dot-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/dot-reporter@13783

@wdio/jasmine-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/jasmine-framework@13783

@wdio/globals

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/globals@13783

@wdio/junit-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/junit-reporter@13783

@wdio/json-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/json-reporter@13783

@wdio/lighthouse-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/lighthouse-service@13783

@wdio/local-runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/local-runner@13783

@wdio/logger

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/logger@13783

@wdio/mocha-framework

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/mocha-framework@13783

@wdio/protocols

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/protocols@13783

@wdio/repl

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/repl@13783

@wdio/reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/reporter@13783

@wdio/runner

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/runner@13783

@wdio/shared-store-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/shared-store-service@13783

@wdio/sauce-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/sauce-service@13783

@wdio/smoke-test-cjs-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-cjs-service@13783

@wdio/smoke-test-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-reporter@13783

@wdio/spec-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/spec-reporter@13783

@wdio/smoke-test-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/smoke-test-service@13783

@wdio/static-server-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/static-server-service@13783

@wdio/sumologic-reporter

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/sumologic-reporter@13783

@wdio/types

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/types@13783

@wdio/utils

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/utils@13783

@wdio/webdriver-mock-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/webdriver-mock-service@13783

webdriver

pnpm add https://pkg.pr.new/webdriverio/webdriverio/webdriver@13783

webdriverio

pnpm add https://pkg.pr.new/webdriverio/webdriverio@13783

@wdio/testingbot-service

pnpm add https://pkg.pr.new/webdriverio/webdriverio/@wdio/testingbot-service@13783

commit: 53533c4

@mykola-mokhnach
Copy link
Contributor

Thanks @christian-bromann

According to the attached SO article the proposed solution does not actually change the current (unexpected) fetch behaviour. E.g. it works for lower timeouts, but is ignored for greater values. I assume it makes sense to use the dispatcher approach instead:

import { Agent } from "undici";

await fetch("https://example.com", {
  dispatcher: new Agent({ connectTimeout: xxx })
});

@christian-bromann
Copy link
Member Author

@mykola-mokhnach dispatcher is not available in native fetch and only is being used in undici.

@mykola-mokhnach
Copy link
Contributor

the original error I pasted is coming from undici.
Perhaps, we could have both options there to make it more error proof?

@christian-bromann
Copy link
Member Author

the original error I pasted is coming from undici.

This is because the Node.js implementation for fetch uses undici. However the goal to use fetch is to be able to use a version that is compatible with running it in the browser and in Node.js. We try to avoid on Node.js specific implmentation and try to use cross platform interfaces wherever possible.

Perhaps, we could have both options there to make it more error proof?

Can you verify if this change maybe fixes the problem. You can test it by adding the following capability to your project:

pnpm add https://pkg.pr.new/webdriverio/webdriverio/webdriverio@13783

@mykola-mokhnach
Copy link
Contributor

the original error I pasted is coming from undici.

This is because the Node.js implementation for fetch uses undici. However the goal to use fetch is to be able to use a version that is compatible with running it in the browser and in Node.js. We try to avoid on Node.js specific implmentation and try to use cross platform interfaces wherever possible.

Perhaps, we could have both options there to make it more error proof?

Can you verify if this change maybe fixes the problem. You can test it by adding the following capability to your project:

pnpm add https://pkg.pr.new/webdriverio/webdriverio/webdriverio@13783

Unfortunately it did not work with my local tests, the request still times out. Perhaps I do something wrong 🤷

@mykola-mokhnach
Copy link
Contributor

I have just added the change to the CI, maybe it would perform better there...

@christian-bromann
Copy link
Member Author

This doesn't seem like to solve the issue, let me get back to the drawing board.

@christian-bromann
Copy link
Member Author

@mykola-mokhnach unfortunately this seems to be an issue with Node.js native fetch implementation. I commented on an issue they have opened for it. In the meantime the best approach would be to use an alternative request library and maybe switch to undici as a fallback for mobile sessions? Wdyt?

@christian-bromann
Copy link
Member Author

Closing in favor of #13852

@christian-bromann christian-bromann deleted the cb/fix-timeout branch November 5, 2024 08:55
christian-bromann added a commit that referenced this pull request Nov 5, 2024
christian-bromann added a commit that referenced this pull request Nov 26, 2024
christian-bromann added a commit that referenced this pull request Nov 26, 2024
* fix(webdriver): use undici for requests in Node.js

* apply changes from #13783

* conditional environment

* fix tests

* fix interop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: connectionRetryTimeout does not affect the actual fetch timeout for greater values

3 participants